FlexReport allows you to export reports to different files and distribute them electronically. It supports the following export formats and respective export filters for exporting the report:
Format |
Description |
RTF (*.rtf) |
RtfFilter export filter is used to export the reports into RTF streams or files. |
Microsoft Excel (*.xlsx/*.xls) |
XlsFilter export filter is used to export the reports into XLSX/XLS streams or files. |
TIFF (*.tiff), BMP, PNG, JPEG, GIF images |
TiffFilter, BmpFilter, PngFilter, JpegFilter, and GifFilter export filters are used to export the reports into different image format filles or streams. |
PDF (*.pdf) |
PdfFilter export filter is used to export the reports into PDF streams or files. |
HTML(*.html) |
HtmlFilter export filter is used to export the reports into HTML streams or files. |
Exporting a report to XLSX format
You can export the report created in Quick Start section to XLSX format using the following steps.
- Add the following namespace in the code view.
Imports C1.Xaml.Document.Export
using C1.Xaml.Document.Export;
- Add the following code to export the report to XLSX format using XlsFilter class.
Note that the same class can be used to export the report to XLS format.
' request target file from the user
Dim fileSavePicker As New FileSavePicker()
fileSavePicker.FileTypeChoices.Add("XLSX files", New String() {".xlsx"})
Dim storageFile As StorageFile = Await fileSavePicker.PickSaveFileAsync()
If storageFile Is Nothing Then
' export cancelled by the user
Return
End If
' initialize XlsFilter
Dim filter As New XlsFilter()
filter.UseZipForMultipleFiles = True
filter.StorageFile = storageFile
' render report to the filter
Await report.RenderToFilterAsync(filter)
' launch the exported file
Await Windows.System.Launcher.LaunchFileAsync(storageFile)
// request target file from the user
FileSavePicker fileSavePicker = new FileSavePicker();
fileSavePicker.FileTypeChoices.Add("XLSX files", new string[] { ".xlsx" });
StorageFile storageFile = await fileSavePicker.PickSaveFileAsync();
if (storageFile == null)
// export cancelled by the user
return;
// initialize XlsFilter
XlsFilter filter = new XlsFilter();
filter.UseZipForMultipleFiles = true;
filter.StorageFile = storageFile;
// render report to the filter
await report.RenderToFilterAsync(filter);
// launch the exported file
await Windows.System.Launcher.LaunchFileAsync(storageFile);
Similarly, you can export your reports to RTF, HTML, and PDF formats.
Exporting a report to an image file format
The above code can be used for exporting a report to an image file but exporting a multi-paged report to an image file only exports the first page of the report at a time as the image format filters do not directly support a multiple paged report in a single file. However, it is possible to generate multiple image files corresponding to each page of a report in a ZIP file. The following code uses one of the image format filter class, JpegFilter, to export the multi-paged report to JPEG format and creates a single ZIP file of the exported images.
' request target file from the user
Dim fileSavePicker As New FileSavePicker()
fileSavePicker.FileTypeChoices.Add("ZIP files", New String() {".zip"})
Dim storageFile As StorageFile = Await fileSavePicker.PickSaveFileAsync()
If storageFile Is Nothing Then
' export cancelled by the user
Return
End If
' initialize JpegFilter
Dim filter As New JpegFilter()
filter.UseZipForMultipleFiles = True
filter.StorageFile = storageFile
' render report to the filter
Await report.RenderToFilterAsync(filter)
' launch the exported file
Await Windows.System.Launcher.LaunchFileAsync(storageFile)
// request target file from the user
FileSavePicker fileSavePicker = new FileSavePicker();
fileSavePicker.FileTypeChoices.Add("ZIP files", new string[] {
".zip"
});
StorageFile storageFile = await fileSavePicker.PickSaveFileAsync();
if (storageFile == null)
// export cancelled by the user
return;
// initialize JpegFilter
JpegFilter filter = new JpegFilter();
filter.UseZipForMultipleFiles = true;
filter.StorageFile = storageFile;
// render report to the filter
await report.RenderToFilterAsync(filter);
// launch the exported file
await Windows.System.Launcher.LaunchFileAsync(storageFile);