Category / Section
How to change default export format type of report
1 min read
Syncfusion Report Writer allows you to change the default file format to any other file format while exporting the document to Microsoft Word and Microsoft Excel. The following code snippet is used to initialize an RDLC report to the Report Writer.
string reportPath = @"../../ReportTemplate/Product Catalog.rdlc"; string fileName = null; WriterFormat format; ReportDataSourceCollection dataSources = new ReportDataSourceCollection(); dataSources.Add(new ReportDataSource { Name = "ProductCatalog", Value = ProductCatalogSource.GetData() }); ReportWriter reportWriter = new ReportWriter(reportPath, dataSources);
The following code snippet illustrates how to change the default file format of exported document.
Word
fileName = "ProductCatalog.docx"; format = WriterFormat.Word; reportWriter.WordOptions = new WordOptions(); reportWriter.WordOptions.FormatType = WordFormatType.Docx;
Excel
fileName = "ProductCatalog.xlsx"; format = WriterFormat.Excel; reportWriter.ExcelOptions = new ExcelOptions(); reportWriter.ExcelOptions.ExcelSaveType = ExcelVersion.Excel2013;