MindFusion.Reporting for Silverlight Programmer's Guide
Exporting Reports

Exporting as PDF

Reports can be easily exported to PDF by using the PdfExporter class. The reports being exported must have been previously processed by a call to their Run method but do not necessarily need to be laid out. The PDF exporter performs internal layouting according to the specified settings.

To export a report to PDF, instantiate from the PdfExporter class and call the Export method. This method takes two arguments - the report to be exported and the file name of the output PDF. Several options can be specified on the PdfExporter object before calling Export, such as the page size and orientation.

 Note

The PdfExporter class is located in the MindFusion.Reporting.Silverlight.PdfExport.dll assembly. In order to use this class, you have to add a reference to this assembly to your project. In addition, the MindFusion.Reporting.Silverlight.PdfExport.dll is dependent on the MindFusion.Common.dll and MindFusion.Pdf.Silverlight.dll assemblies, so you will have to deploy those two as well (although it might not be necessary to reference them directly in your project).

Several enumerations used by the PdfExporter class, such as PageSize and PageOrientation are located in MindFusion.Pdf.Silverlight.dll.

The following code illustrates how to export an existing report (identified by the report variable) to a PDF:

C#  Copy Code

PdfExporter exporter = new PdfExporter();
exporter.PageSize = MindFusion.Pdf.Silverlight.PageSize.A3;
exporter.PageOrientation = MindFusion.Pdf.Silverlight.PageOrientation.Landscape;
exporter.Export(report, "report.pdf");

Visual Basic  Copy Code

Dim exporter As New PdfExporter()
exporter.PageSize = MindFusion.Pdf.Silverlight.PageSize.A3
exporter.PageOrientation = MindFusion.Pdf.Silverlight.PageOrientation.Landscape
exporter.Export(report, "report.pdf")

Exporting as MHTML

Exporting to MHTML is very similar to exporting to PDF - you create an instance of the MhtmlExporter class, set the desired options and call the Export method. As is usual, the exported report must have been previously run by a call to its Run method. Several options can be specified on the exporter including page size and margins.

 Note

The MhtmlExporter class is located in the MindFusion.Reporting.Silverlight.HtmlExport.dll assembly. In order to use this class, you have to add a reference to this assembly to your project.

Exporting as XLSX

Similarly to the other exporters, create an instance of the ExcelExporter class, set the desired options and call the Export method. As is usual, the exported report must have been previously run by a call to its Run method. Several options can be specified on the ExcelExporter including page size and margins.

 Note

The ExcelExporter class is located in the MindFusion.Reporting.Silverlight.ExcelExport.dll assembly. In order to use this class, you have to add a reference to this assembly to your project.

The following code illustrates how to export an existing report to an XLSX:

C#  Copy Code

ExcelExporter exporter = new ExcelExporter();
exporter.Export(report, "report.xlsx");

VB.NET  Copy Code

Dim exporter As New ExcelExporter()
exporter.Export(report, "report.xlsx")