Export report
To control and customize report export in the Bold Reports® UWP Report Viewer, use its export properties. You can set PDF, Word, Excel, PowerPoint, CSV, and HTML options, and protect exported documents.
PDF export options
The PDFOptions class provides properties to manage PDF export behaviors in the UWP Report Viewer. Set the properties in the application window loaded method.
How do I export reports with complex scripts?
To export reports with complex scripts from the UWP Report Viewer, set the EnableComplexScript property of PDFOptions instance to true.
this.ReportViewer.PDFOptions = new BoldReports.Writer.PDFOptions();
this.ReportViewer.PDFOptions.EnableComplexScript = true;PDF Conformance
To export the report as a PDF/A-1b document from the UWP Report Viewer, specify the conformance level PdfConformanceLevel.Pdf_A1B in the PdfConformanceLevel property.
this.ReportViewer.PDFOptions = new BoldReports.Writer.PDFOptions();
this.ReportViewer.PDFOptions.PdfConformanceLevel = Syncfusion.Pdf.PdfConformanceLevel.Pdf_A1B;How do I add custom fonts to an exported PDF document?
To add custom fonts to a PDF document exported from the UWP Report Viewer, add the font streams to the Fonts collection in the PDFOptions instance.
- Add the font
.ttffiles into your applicationResourcesfolder. - In the Solution Explorer, open the properties of the font file and set the property Copy to Output Directory as Copy always.
- Initialize the
Fontcollection and add the font stream to it.
The key value provided in the font collection should be same as in the report item font property.
this.ReportViewer.PDFOptions = new BoldReports.Writer.PDFOptions()
{
Fonts = new Dictionary<string, System.IO.Stream>
{
{ "Segoe UI", assembly.GetManifestResourceStream("ReportViewer_UWP.Resources.font_symbols.ttf") }
}
};Any fonts used in the report definition that is not installed or available in the local system, then you must load the font stream. In the above code, loaded
font_symbolsfont stream to exportsales-order-detail.rdlreport as symbols.
Word export options
The WordOptions class provides properties to manage Word document export behaviors in the UWP Report Viewer.
Word document type
To save the report to the required Word document version, set the FormatType property.
this.ReportViewer.WordOptions = new BoldReports.Writer.WordOptions();
this.ReportViewer.WordOptions.FormatType = BoldReports.Writer.WordFormatType.Docx;Word document advance layout for merged cells
Eliminate the tiny columns, rows, merged cells, and render the word document elements without nested grid layout by setting the LayoutOption as TopLevel. The ParagraphSpacing is the distance value added between two elements in the document.
this.ReportViewer.WordOptions = new BoldReports.Writer.WordOptions();
this.ReportViewer.WordOptions.LayoutOption = BoldReports.Writer.WordLayoutOptions.TopLevel;
this.ReportViewer.WordOptions.ParagraphSpacing = new BoldReports.Writer.ParagraphSpacing()
{
Bottom = 0.5f,
Top = 0.5f
};A paragraph element is inserted between two tables in the exported document to overcome word document auto merging behavior. The table in word document is not a stand-alone object, if you draw two tables one after another, it will automatically get merged into a single table. To prevent this merging, added an empty paragraph between two tables.
How do I protect an exported Word document from editing?
To protect a Word document exported from the UWP Report Viewer, restrict editing either with a password or without a password. The following are the types of protection.
AllowOnlyComments: You can add or modify only the comments in the Word document.AllowOnlyFormFields: You can modify the form field values in the Word document.AllowOnlyRevisions: You can accept or reject the revisions in the Word document.AllowOnlyReading: You can only view the content in the Word document.NoProtection: You can access or edit the Word document contents as normally.
this.ReportViewer.WordOptions = new BoldReports.Writer.WordOptions();
this.ReportViewer.WordOptions.ProtectionType = Syncfusion.DocIO.ProtectionType.AllowOnlyReading;Excel export options
The ExcelOptions class provides properties to manage Excel document export behaviors in the UWP Report Viewer.
Excel document type
To save the report to the required Excel version, set the ExcelSaveType property.
this.ReportViewer.ExcelOptions = new BoldReports.Writer.ExcelOptions();
this.ReportViewer.ExcelOptions.ExcelSaveType = BoldReports.Writer.ExcelVersion.Excel2013;Excel document advance layout for merged cells
Eliminate the tiny columns, rows, and merged cells to provide clear readability and perform data manipulations by setting the LayoutOption as IgnoreCellMerge.
this.ReportViewer.ExcelOptions = new BoldReports.Writer.ExcelOptions();
this.ReportViewer.ExcelOptions.LayoutOption = BoldReports.Writer.ExcelLayoutOptions.IgnoreCellMerge;How do I protect an exported Excel document from editing?
To protect an Excel document exported from the UWP Report Viewer, restrict editing either by providing the ExcelSheetProtection or enabling the ReadOnlyRecommended properties.
this.ReportViewer.ExcelOptions = new BoldReports.Writer.ExcelOptions()
{
ReadOnlyRecommended = true,
ExcelSheetProtection = Syncfusion.XlsIO.ExcelSheetProtection.DeletingColumns
};PowerPoint export options
To save the report to the required PowerPoint version in the UWP Report Viewer, set the FormatType property.
this.ReportViewer.PPTOptions = new BoldReports.Writer.PPTOptions();
this.ReportViewer.PPTOptions.FormatType = BoldReports.Writer.PPTSaveType.PowerPoint2013;CSV export options
The CsvOptions class lets you change the encoding, delimiters, qualifiers, extension, and line break of a CSV document exported from the UWP Report Viewer.
this.ReportViewer.CsvOptions = new BoldReports.Writer.CsvOptions()
{
Encoding = System.Text.Encoding.Default,
FieldDelimiter = ",",
UseFormattedValues = false,
Qualifier = "#",
RecordDelimiter = "@",
SuppressLineBreaks = true,
FileExtension = ".txt"
};HTML export options
To hide the separator added at the end of each page in an HTML export from the UWP Report Viewer, set the HidePageSeparator property to true.
this.ReportViewer.HTMLOptions = new BoldReports.Writer.HTMLOptions();
this.ReportViewer.HTMLOptions.HidePageSeparator = true;How do I password protect an exported document?
To protect an exported PDF, Word, Excel, or PowerPoint document from unauthorized users, encrypt the document with an encryption password in the UWP Report Viewer. The following code snippet illustrates how to encrypt the exported document with the user-defined password.
//PDF encryption
this.ReportViewer.PDFOptions = new BoldReports.Writer.PDFOptions();
this.ReportViewer.PDFOptions.Security = new Syncfusion.Pdf.Security.PdfSecurity()
{
UserPassword = "Password"
};
//Word encryption
this.ReportViewer.WordOptions = new BoldReports.Writer.WordOptions()
{
EncryptionPassword = "password"
};
//Excel encryption
this.ReportViewer.ExcelOptions = new BoldReports.Writer.ExcelOptions()
{
PasswordToModify = "password",
PasswordToOpen = "password"
};
//PPT encryption
this.ReportViewer.PPTOptions = new BoldReports.Writer.PPTOptions()
{
EncryptionPassword = "password"
};Password protection is not supported for HTML export format.
How do I change the file name of an exported report?
To change the file name of a report exported from the UWP Report Viewer, use the FileName property.
this.ReportViewer.ExportSettings = new BoldReports.Writer.ExportSettings();
this.ReportViewer.ExportSettings.FileName = "Invoice";How do I change the image quality in an exported report?
To change the image quality of data visualization items in a report exported from the UWP Report Viewer, use the ImageQuality property.
this.ReportViewer.ExportSettings = new BoldReports.Writer.ExportSettings();
this.ReportViewer.ExportSettings.ImageQuality = 4;