ActiveReports 15 .NET Edition
ActiveReports 15 User Guide / Export Reports / Export Filters / Exporting Reports using Export Filters
In This Topic
    Exporting Reports using Export Filters
    In This Topic

    ActiveReports provides various export filters that can be used to export Section Reports to the supported file formats.

    Note: In the CrossPlatform compatibility mode, ActiveReports uses the custom font settings that you specify in a section report or in the ActiveReports configuration file

    Only the TIFF and PDF exports are WYSIWYG. Other export formats do not embed fonts, so their visual output may differ from an original report.

    Note: In ActiveReports, by default, the NuGet packages are located in the ...\GrapeCity\ActiveReports 15\NuGet folder.

    Use the following steps to export reports through export filters. These steps assume that you have already created a Windows Application and added the export controls to your Visual Studio toolbox. For more information, see Adding ActiveReports Controls.

    To export a report

    1. Create a new project or open an existing Windows Forms Application in Visual Studio.
    2. If you are creating a new project, select ActiveReports 15 Section Report (xml-based) in the New Project dialog and click OK.

      If you are using an existing project, in the Solution Explorer, right-click the project and select Add > New Item.
    3. Select any of the report items from ActiveReports 15 Section Report (xml-based) and click Add.
    4. Install Export packages from nuget as follows:
      i) Go to Tools > Nuget Package Manager > Manage Nuget Packages for Solution...
      ii) Browse the following packages one by one and click Install.
         GrapeCity.ActiveReports.Export.Excel
         GrapeCity.ActiveReports.Export.Html
         GrapeCity.ActiveReports.Export.Image
         GrapeCity.ActiveReports.Export.Pdf
         GrapeCity.ActiveReports.Export.Word
         GrapeCity.ActiveReports.Export.Xml
    5. In your project's Bin>Debug folder, place the report.rpx (Section Report).    
    6. On the Form.cs or Form.vb, double-click the title bar to create the Form_Load event.
    7. In Form_Load event, add the following code to add a report to your project.  

      To add Section report to your project

      Visual Basic.NETcode. Paste INSIDE the Form_Load event.
      Copy Code
      ' Create a Section report.
      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()
      Dim MyDocument As New GrapeCity.ActiveReports.Document.SectionDocument ("rpt")
      C# code. Paste INSIDE the Form_Load event.
      Copy Code
      // Create a Section report.
      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();
      GrapeCity.ActiveReports.Document.SectionDocument MyDocument = new GrapeCity.ActiveReports.Document.SectionDocument("rpt");
    8. Add the following code to export Section Reports to multiple format.        

      To write the code in Visual Basic.NET

      Visual Basic.NET code. Paste INSIDE the Form_Load event.
      Copy Code
      ' Export the report in HTML format.
      Dim HtmlExport1 As New GrapeCity.ActiveReports.Export.Html.Section.HtmlExport()
      HtmlExport1.Export(MyDocument, Application.StartupPath + "\HTMLExpt.html")
      
      ' Export the report in PDF format.
      Dim PdfExport1 As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport()
      PdfExport1.Export(MyDocument, Application.StartupPath + "\PDFExpt.pdf")
      
      ' Export the report in RTF format.
      Dim RtfExport1 As New GrapeCity.ActiveReports.Export.Word.Section.RtfExport()
      RtfExport1.Export(MyDocument, Application.StartupPath + "\RTFExpt.rtf")
      
      ' Export the report in text format.
      Dim TextExport1 As New GrapeCity.ActiveReports.Export.Xml.Section.TextExport()
      TextExport1.Export(MyDocument, Application.StartupPath + "\TextExpt.txt")
      
      ' Export the report in TIFF format.
      Dim TiffExport1 As New GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport()
      TiffExport1.Export(MyDocument, Application.StartupPath + "\TIFFExpt.tiff")
      
      ' Export the report in Excel format.
      Dim XlsExport1 As New GrapeCity.ActiveReports.Export.Excel.Section.XlsExport()
      ' Set a file format of the exported excel file to Xlsx to support Microsoft Excel 2007 and newer versions.
      XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx
      XlsExport1.Export(MyDocument, Application.StartupPath + "\XLSExpt.xlsx")                                        
      

      To write the code in C#

      C# code. Paste INSIDE the Form_Load event.
      Copy Code
      // Export the report in HTML format.
      GrapeCity.ActiveReports.Export.Html.Section.HtmlExport HtmlExport1 = new GrapeCity.ActiveReports.Export.Html.Section.HtmlExport();
      HtmlExport1.Export(MyDocument, 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(MyDocument, 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(MyDocument, 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(MyDocument, 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(MyDocument, Application.StartupPath + "\\TIFFExpt.tiff");
      
      // Export the report in XLSX format.
      GrapeCity.ActiveReports.Export.Excel.Section.XlsExport XlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
      // Set a file format of the exported excel file to Xlsx to support Microsoft Excel 2007 and newer versions.
      XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
      XlsExport1.Export(MyDocument, Application.StartupPath + "\\XLSExpt.xlsx");                  
      
      Note: When exporting a report to .MHT file by Export filters use htmlExport.Export(Document doc, Stream outputStream);
      For more information, see HTML Export Method.
    9. Press F5 to run the application. The exported files are saved in the bin\debug folder.
    See Also