MindFusion WinForms Programmer's Guide
Exporting

Currently MindFusion.Reporting reports support exporting to image, PDF, HTML, and XLSX formats.

Exporting to PDF Files

Add references to the MindFusion.Reporting.Pdf.dll and MindFusion.Pdf.dll assemblies to your project. Create a PdfExporter instance and call its Export method, passing a reference to the report to be exported and a string specifying the output file name. Margins specifies the page margins for all pages in the document. If you need to set the page size and orientation, use the PageSize, and PageOrientation properties.

The following example shows how to export a report to a PDF file. The example assumes that pdfPath is a variable containing the name of the file to export to and report is a variable identifying the Report to export.

C#  Copy Code

MindFusion.Reporting.Export.PdfExporter pdfExporter =
    new MindFusion.Reporting.Export.PdfExporter();
pdfExporter.Export(report, pdfPath);

Visual Basic  Copy Code

Dim pdfExporter As New MindFusion.Reporting.Export.PdfExporter()
pdfExporter.Export(report, pdfPath)

Exporting to HTML Files

Add reference to the MindFusion.Reporting.Html.dll assembly to your project. Create an HtmlExporter instance and call one of its Export method overloads.

If there are images in the report, set EmbedImages to true to embed the images in the HTML as text. If this property is set to false, the images will be copied to the directory specified by the ImageFolder property. This property can also specify a directory relative to the output directory of the exported HTML file.

 Note

Not all browsers can handle embedded images. Make sure the target browser supports them when using the EmbedImages property.

The following example demonstrates the use of the HtmlExporter class. The example assumes that pdfPath is a variable containing the name of the file to export to and report is a variable identifying the Report to export.

C#  Copy Code

MindFusion.Reporting.Export.HtmlExporter htmlExporter =
    new MindFusion.Reporting.Export.HtmlExporter();
htmlExporter.Export(report, htmlPath);

Visual Basic  Copy Code

Dim htmlExporter As New MindFusion.Reporting.Export.HtmlExporter()
htmlExporter.Export(report, htmlPath)

The HtmlExporter class provides a second overload of the Export method, which exports the report to a .NET StringBuilder rather than a file. This is useful when you want to embed the report in a custom page, for example, within a scrollable DIV tag.

Exporting to MHTML Files

Exporting to MHTML is similar to exporting to HTML. It is done through the MhtmlExporter class.

Exporting to Image

The following example demonstrates the use of the ImageExporter class. The example assumes that imagePath is a variable containing the name of the file to export to and report is a variable identifying the Report to export.

C#  Copy Code

MindFusion.Reporting.Export.ImageExporter imageExporter =
    new MindFusion.Reporting.Export.ImageExporter();
imageExporter.Export(report, imagePath);

VB.NET  Copy Code

Dim imageExporter As New MindFusion.Reporting.Export.ImageExporter()
imageExporter.Export(report, imagePath)

Exporting to Open Office XML (XLSX) Files

Add references to the MindFusion.Reporting.Excel.dll and MindFusion.Excel.dll assemblies to your project. Create an ExcelExporter instance and call its Export method, passing a reference to the report to be exported and a string specifying the output file name. Margins specifies the page margins for all pages in the document. If you need to set the page size and orientation, use the PageSize, and PageOrientation properties.

The following example shows how to export a report to an XLSX file. The example assumes that xlsxPath is a variable containing the name of the file to export to and report is a variable identifying the Report to export.

C#  Copy Code

MindFusion.Reporting.Export.ExcelExporter excelExporter =
    new MindFusion.Reporting.Export.ExcelExporter();
excelExporter.Export(report, xlsxPath);

VB.NET  Copy Code

Dim excelExporter As New MindFusion.Reporting.Export.ExcelExporter()
excelExporter.Export(report, xlsxPath)