ActiveReports Developer 7
Export a Section Report
See Also Support Forum
ActiveReports Developer 7 > ActiveReports Developer Guide > How To > Section Report How To > Export a Section Report

Glossary Item Box

In a section report, in order to export your reports to the various formats that ActiveReports Developer supports, you must first either add reference to the assemblies listed below or add the required export controls to your Visual Studio toolbox. For more information on how to add controls, see the Adding ActiveReports Controls topic.

Here are the export formats that ActiveReports Developer supports along with the necessary assembly reference:

Note: HTML Export requires the .NET Framework full profile version. To ensure you are using the full profile version, go to the Visual Studio Project menu > Properties > Compile tab > Advanced Compile Options (for Visual Basic projects) or to the Project menu > Properties > Application tab (for C# projects) and under Target framework select a full profile version.

Use the following steps to export reports through export filters.

  1. Place the report.rpx report inside your project's Bin>Debug folder.
  2. In the Solution Explorer, right-click the References node and select Add Reference.
  3. In the Add Reference dialog that appears, select the following references and click OK to add them to your project.
    GrapeCity.ActiveReports.Export.Excel.v7
    GrapeCity.ActiveReports.Export.Html.v7
    GrapeCity.ActiveReports.Export.Image.v7
    GrapeCity.ActiveReports.Export.Pdf.v7
    GrapeCity.ActiveReports.Export.Word.v7
    GrapeCity.ActiveReports.Export.Xml.v7
    Note: The relevant export assemblies are added automatically if you add the export control to the Form. In case you have already done so, you may skip steps 2 and 3 above.
  4. Double-click the Windows Form to create a Form_Load event.
  5. Add the following code to the event to export the report in various formats.

    ShowTo write the code in Visual Basic.NET

    Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code

    Dim rpt As New GrapeCity.ActiveReports.SectionReport()
    ' For the code to work, report.rpx must be placed in the bin\debug folder of your project.
    Dim xtr As New System.Xml.XmlTextReader(Application.StartupPath + "\report.rpx")
    rpt.LoadLayout(xtr)
    rpt.Run()
    ' Export the report in HTML format.
    Dim htmlExport1 As New GrapeCity.ActiveReports.Export.Html.Section.HtmlExport()
    htmlExport1.Export(rpt.Document, Application.StartupPath + "\\HTMLExpt.html")
    ' Export the report in PDF format.
    Dim pdfExport1 As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport()
    pdfExport1.Export(rpt.Document, Application.StartupPath + "\\PDFExpt.pdf")
    ' Export the report in RTF format.
    Dim rtfExport1 As New GrapeCity.ActiveReports.Export.Word.Section.RtfExport()
    rtfExport1.Export(rpt.Document, Application.StartupPath + "\\RTFExpt.rtf")
    ' Export the report in text format.
    Dim textExport1 As New GrapeCity.ActiveReports.Export.Xml.Section.TextExport()
    textExport1.Export(rpt.Document, Application.StartupPath + "\\TextExpt.txt")
    ' Export the report in TIFF format.
    Dim tiffExport1 As New GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport()
    tiffExport1.Export(rpt.Document, Application.StartupPath + "\\TIFFExpt.tiff")
    ' Export the report in Excel format.
    Dim xlsExport1 As New GrapeCity.ActiveReports.Export.Excel.Section.XlsExport()
    xlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx
    ' Set the file format of the exported excel file to Xlsx to support Microsoft Excel 2007 and newer versions.
    xlsExport1.Export(rpt.Document, Application.StartupPath + "\\XLSExpt.xlsx")

    ShowTo write the code in C#

    C# code. Paste INSIDE the Form Load event. Copy Code
    GrapeCity.ActiveReports.SectionReport rpt = new GrapeCity.ActiveReports.SectionReport();
    // For the code to work, report.rpx must be placed in the bin\debug folder of your project.
    System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + "\\report.rpx");
    rpt.LoadLayout(xtr);
    rpt.Run();
    // Export the report in HTML format.
    GrapeCity.ActiveReports.Export.Html.Section.HtmlExport htmlExport1 = new GrapeCity.ActiveReports.Export.Html.Section.HtmlExport();
    htmlExport1.Export(rpt.Document, Application.StartupPath + "\\HTMLExpt.html"); 
    // Export the report in PDF format.
    GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdfExport1 = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
    pdfExport1.Export(rpt.Document, Application.StartupPath + "\\PDFExpt.pdf"); // Export the report in RTF format. GrapeCity.ActiveReports.Export.Word.Section.RtfExport rtfExport1 = new GrapeCity.ActiveReports.Export.Word.Section.RtfExport(); rtfExport1.Export(rpt.Document, Application.StartupPath + "\\RTFExpt.rtf"); // Export the report in text format. GrapeCity.ActiveReports.Export.Xml.Section.TextExport textExport1 = new GrapeCity.ActiveReports.Export.Xml.Section.TextExport(); textExport1.Export(rpt.Document, Application.StartupPath + "\\TextExpt.txt"); // Export the report in TIFF format. GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport tiffExport1 = new GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport(); tiffExport1.Export(rpt.Document, Application.StartupPath + "\\TIFFExpt.tiff"); // Export the report in XLSX format. GrapeCity.ActiveReports.Export.Excel.Section.XlsExport xlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
    xlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx; // Set the file format of the exported excel file to Xlsx to support Microsoft Excel 2007 and newer versions. xlsExport1.Export(rpt.Document, Application.StartupPath + "\\XLSExpt.xlsx");
  6. Press F5 to run the application. The exported files are saved in the bin\debug folder.

See Also

©2014. ComponentOne, a division of GrapeCity. All rights reserved.