Exemple #1
0
        /// <summary>
        /// Determines whether the specified <see cref="ISectionFooter"/> is equal to this instance.
        /// </summary>
        /// <param name="other">The <see cref="ISectionFooter"/> to compare with this instance.</param>
        /// <returns><c>true</c> if the specified <see cref="ISectionFooter"/> is equal to this instance;
        /// otherwise, <c>false</c>.</returns>
        public bool Equals(ISectionFooter other)
        {
            SectionFooter header = other as SectionFooter;

            if (header != null)
            {
                return(Pair == header.Pair);
            }

            return(Pair == other);
        }
Exemple #2
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to this instance;
        /// otherwise, <c>false</c>.</returns>
        public override bool Equals(object obj)
        {
            SectionFooter header = obj as SectionFooter;

            if (header != null)
            {
                return(Pair == header.Pair);
            }

            ISectionFooter iheader = obj as ISectionFooter;

            if (iheader != null)
            {
                return(Pair == iheader);
            }

            return(false);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="toFile">Name of the file to export to</param>
        /// <param name="headerText">Main Header text</param>
        /// <param name="subheadingText">Sub-heading text</param>
        /// <param name="footerText">footer text</param>
        /// <param name="grid">Grid View to export</param>
        /// <param name="outputFormat">Output format</param>
        public static void Export(String toFile
                                  , String headerText
                                  , String subheadingText
                                  , String footerText
                                  , UltraGrid grid
                                  , FileFormat outputFormat)
        {
            // Create the report itself
            Report report = new Report();

            // ...then the sections for header, footer and body
            ISection mainSection = report.AddSection();

            mainSection.PageMargins = new Infragistics.Documents.Reports.Report.Margins(50);
            ISectionHeader headerSection = mainSection.AddHeader();

            headerSection.Height = 50;
            headerSection.Repeat = true;

            // Add a footer for page numbering
            ISectionFooter footerSection = mainSection.AddFooter();

            // Create place-holder for header text
            Infragistics.Documents.Reports.Report.Text.IText headerTextSection = headerSection.AddText(0, 0);

            // ...and add the header in to this section, centralized
            headerTextSection.AddContent(headerText);
            headerTextSection.Alignment.Horizontal = Alignment.Center;
            headerTextSection.Alignment.Vertical   = Alignment.Middle;

            // Set style for the header
            Infragistics.Documents.Reports.Report.Text.Style HeaderStyle = new Infragistics.Documents.Reports.Report.Text.Style(new Infragistics.Documents.Reports.Graphics.Font("Verdana", 10, Infragistics.Documents.Reports.Graphics.FontStyle.Underline), Infragistics.Documents.Reports.Graphics.Brushes.DarkBlue);
            headerTextSection.Style = HeaderStyle;

            // Add in a sub-heading if required
            if (subheadingText != null && subheadingText != "")
            {
                headerTextSection = headerSection.AddText(0, 20);
                Infragistics.Documents.Reports.Report.Text.Style subHeaderStyle = new Infragistics.Documents.Reports.Report.Text.Style(new Infragistics.Documents.Reports.Graphics.Font("Verdana", 8, Infragistics.Documents.Reports.Graphics.FontStyle.Underline), Infragistics.Documents.Reports.Graphics.Brushes.DarkBlue);
                headerTextSection.Style = subHeaderStyle;
                headerTextSection.AddContent(subheadingText);
            }

            // Add the body of the report which is the contents of the grid
            UltraGridDocumentExporter exporter = new UltraGridDocumentExporter();

            exporter.Export(grid, mainSection);

            //-------------------------
            // Setup Footer content
            //-------------------------
            footerSection.Height = 50;

            // Do we have a footer to display?
            if (footerText != null && footerText != "")
            {
                // Create place-holder for footer text
                Infragistics.Documents.Reports.Report.Text.IText footerTextSection = footerSection.AddText(0, 0);

                // ...and add the footer text in to this section, left aligned
                footerTextSection.Alignment.Horizontal = Alignment.Left;
                footerTextSection.Alignment.Vertical   = Alignment.Top;

                // Set style for the text
                Infragistics.Documents.Reports.Report.Text.Style footerStyle = new Infragistics.Documents.Reports.Report.Text.Style(new Infragistics.Documents.Reports.Graphics.Font("Verdana", 6, Infragistics.Documents.Reports.Graphics.FontStyle.Underline), Infragistics.Documents.Reports.Graphics.Brushes.DarkBlue);
                footerTextSection.Style = footerStyle;

                // ...and set the text itself
                footerTextSection.AddContent(footerText);
            }

            PageNumbering pn = mainSection.PageNumbering;

            // The Template property is the actual string that shows the page numbering. Use the [Page #] place-
            // holder for the current page and the [TotalPages] place-holder for the total amount of pages in
            // the entire document.
            pn.Template = "Page [Page #] of [TotalPages]";

            // Setting SkipFirst to true does not place page numbering on the first page of the section. This
            // is useful if the first page is a Title page.
            pn.SkipFirst = false;

            // The page numbering will be aligned with the right side of the page. Valid values off the
            // Alignment enum include Left, Center, and Right.
            pn.Alignment.Horizontal = Alignment.Right;

            // The page numbering will be located at the bottom of the page. Valid values off the
            // Alignment enum include Top and Bottom.
            pn.Alignment.Vertical = Alignment.Bottom;

            // The page numbering is at the extreme bottom of the page, so we need to change the Y Offset
            // in order to bring it in line with the rest of the page footer text.
            pn.OffsetY = -18;

            // Delete the old report if it exists
            try
            {
                if (File.Exists(toFile))
                {
                    File.Delete(toFile);
                }
            }
            catch (Exception)
            {
                //Ignore any errors
            }

            // Generate the report
            try
            {
                report.Generate();
                report.Publish(toFile, outputFormat);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to write the export file " + toFile + ", the error was " + ex.Message);
            }
        }
        /// <summary>
        /// Export the
        /// </summary>
        /// <param name="ToFile"></param>
        /// <param name="listSections"></param>
        /// <param name="outputFormat"></param>
        public static void Export(string toFile, UltraGrid grid, ExportSectionList listSections, FileFormat outputFormat)
        {
            // Create the report itself
            Report report = new Report();

            // ...then the sections for header, footer and body
            ISection mainSection = report.AddSection();

            mainSection.PageMargins = new Infragistics.Documents.Reports.Report.Margins(50);
            ISectionHeader headerSection = mainSection.AddHeader();

            headerSection.Height = 50;
            headerSection.Repeat = true;
            ISectionFooter footerSection = mainSection.AddFooter();

            footerSection.Height = 50;

            // Add the body of the report which is the contents of the grid
            UltraGridDocumentExporter exporter = new UltraGridDocumentExporter();

            exporter.Export(grid, mainSection);

            // Setup the page numbering
            PageNumbering pn = mainSection.PageNumbering;

            // The Template property is the actual string that shows the page numbering. Use the [Page #] place-
            // holder for the current page and the [TotalPages] place-holder for the total amount of pages in
            // the entire document.
            pn.Template = "Page [Page #] of [TotalPages]";

            // Setting SkipFirst to true does not place page numbering on the first page of the section. This
            // is useful if the first page is a Title page.
            pn.SkipFirst = false;

            // The page numbering will be aligned with the right side of the page. Valid values off the
            // Alignment enum include Left, Center, and Right.
            pn.Alignment.Horizontal = Alignment.Right;

            // The page numbering will be located at the bottom of the page. Valid values off the
            // Alignment enum include Top and Bottom.
            pn.Alignment.Vertical = Alignment.Bottom;

            // The page numbering is at the extreme bottom of the page, so we need to change the Y Offset
            // in order to bring it in line with the rest of the page footer text.
            pn.OffsetY = -18;

            // Delete the old report if it exists
            try
            {
                if (File.Exists(toFile))
                {
                    File.Delete(toFile);
                }
            }
            catch (Exception)
            {
                //Ignore any errors
            }

            // Generate the report
            try
            {
                report.Generate();
                report.Publish(toFile, outputFormat);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to write the export file " + toFile + ", the error was " + ex.Message);
            }
        }