[]
Excel Data is one of the formats to which you can render your report using ExcelTransformationDevice. You can export excel files in two formats, Xlsx and Csv.
Excel Data exports only data from Tablix, Table, and Matrix data regions, preserving the data region structure and ignoring layout-related features (page break, cumulative total, etc). Other controls and data regions of the original report are ignored at this export. The FrozenRows and FrozenColumns settings of Table and Tablix are handled at the report export and can be applied in the exported file.
type=note
Note: If a report does not contain any data region (Table or Tablix), a Csv file is not generated.
For the Xlsx format, when a report has multiple data regions, each data region is exported to a separate excel sheet.
For the Csv format, a separate CSV file is created for each data region, available in the report.
The following steps provide an example of rendering a report in the Microsoft Excel format.
Create a new or open an existing Windows Forms App in Visual Studio project.
Go to the Project Explorer, right-click the project and select Add > New Item.
Select ActiveReports 19 Standalone Report > Add and choose a report type, RDLX, RDLX Dashboard, or Page report and then click Finish.
Add MESCIUS.ActiveReports.Export.Excel package in the project.
On the Form.cs or Form.vb that opens, double-click the title bar to create the Form_Load event.
Add the following code inside the Form_Load event.
### Csv Data
' Provide the Page Report you want to render.
Dim rptPath As System.IO.FileInfo = New System.IO.FileInfo("..\..\..\Report1.rdlx")
Dim pageReport As GrapeCity.ActiveReports.PageReport = New GrapeCity.ActiveReports.PageReport(rptPath)
' Create an output directory.
Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyCsvData")
outputDirectory.Create()
' Provide settings for your rendering output.
Dim settings = New GrapeCity.ActiveReports.Export.Excel.Page.Settings()
settings.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.ExcelDataFileFormat.Csv
settings.Csv.ColumnsDelimiter = ","
settings.Csv.Encoding = System.Text.Encoding.UTF8
settings.Csv.NoHeader = False
settings.Csv.QuotationSymbol = """"c
settings.Csv.RowsDelimiter = vbCrLf
' Set the rendering extension and render the report.
Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))
' Overwrite output file if it already exists.
outputProvider.OverwriteOutputFile = True
pageReport.Document.Render(New GrapeCity.ActiveReports.Export.Excel.Page.ExcelTransformationDevice(), outputProvider, settings)
// Provide the Page Report you want to render.
System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\..\Report1.rdlx");
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);
// Create an output directory.
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyCsvData");
outputDirectory.Create();
// Provide settings for your rendering output.
var settings = new GrapeCity.ActiveReports.Export.Excel.Page.Settings();
settings.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.ExcelDataFileFormat.Csv;
settings.Csv.ColumnsDelimiter = ",";
settings.Csv.Encoding = Encoding.UTF8;
settings.Csv.NoHeader = false;
settings.Csv.QuotationSymbol = '"';
settings.Csv.RowsDelimiter = "\r\n";
// Set the rendering extension and render the report.
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
// Overwrite output file if it already exists.
outputProvider.OverwriteOutputFile = true;
pageReport.Document.Render(new GrapeCity.ActiveReports.Export.Excel.Page.ExcelTransformationDevice(), outputProvider, settings);
### Excel Data
' Provide the Page Report you want to render.
Dim rptPath As System.IO.FileInfo = New System.IO.FileInfo("..\..\..\Report1.rdlx")
Dim pageReport As GrapeCity.ActiveReports.PageReport = New GrapeCity.ActiveReports.PageReport(rptPath)
' Create an output directory.
Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyExcelData")
outputDirectory.Create()
' Provide settings for your rendering output.
Dim settings = New GrapeCity.ActiveReports.Export.Excel.Page.Settings()
settings.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.ExcelDataFileFormat.Xlsx
settings.Xlsx.AllowImages = True
settings.Xlsx.UseCompression = True
settings.Xlsx.OpenXmlStandard = GrapeCity.ActiveReports.Export.Excel.Page.OpenXmlStandard.Transitional
settings.Xlsx.Security.ReadOnlyRecommended = True
' Set the rendering extension and render the report.
Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))
' Overwrite output file if it already exists.
outputProvider.OverwriteOutputFile = True
pageReport.Document.Render(New GrapeCity.ActiveReports.Export.Excel.Page.ExcelTransformationDevice(), outputProvider, settings)
// Provide the Page Report you want to render.
System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\..\Report1.rdlx");
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);
// Create an output directory.
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyExcelData");
outputDirectory.Create();
// Provide settings for your renderidng output.
var settings = new GrapeCity.ActiveReports.Export.Excel.Page.Settings();
settings.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.ExcelDataFileFormat.Xlsx;
settings.Xlsx.AllowImages = true;
settings.Xlsx.UseCompression = true;
settings.Xlsx.OpenXmlStandard = GrapeCity.ActiveReports.Export.Excel.Page.OpenXmlStandard.Transitional;
settings.Xlsx.Security.ReadOnlyRecommended = true;
// Set the rendering extension and render the report.
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
// Overwrite output file if it already exists.
outputProvider.OverwriteOutputFile = true;
pageReport.Document.Render(new GrapeCity.ActiveReports.Export.Excel.Page.ExcelTransformationDevice(), outputProvider, settings);
ActiveReports offers several options to control how reports render to Excel Data.
Property | Description |
---|---|
Csv | Csv related properties. See Csv Rendering Properties below. |
Indicates whether to use Csv or OpenXml format for the output file. | |
Xlsx | OpenXml related properties. See Xlsx Rendering Properties below. |
Property | Description |
---|---|
Sets or returns the text inserted between columns. | |
Specifies the default format for date values, for example, 'yyyy-MM-dd'. | |
Specifies the encoding schema for output. | |
Specifies whether to omit the CSV Header. | |
Specifies the format for numeric values, for example, '0.####'. | |
Sets or returns the qualifier character to put around results. | |
Sets or returns the text inserted between rows. |
Property | Description |
---|---|
Indicates whether to allow images or just plain data content. | |
Sets the name of the author that appears in the Author field in the Properties of the exported Excel document. | |
Indicates whether to export rows height or specify auto height. | |
Sets the name of the categories that appears in the Categories field in the Properties of the exported Excel document. | |
Specifies the level of Open XML document conformance on exporting in Xlsx file format. You can choose from the following values: * Transitional: The default value. * Strict: The Excel file generated using Strict cannot be viewed on iOS devices. | |
Shows direction of sheets from right to left. | |
Initializes the document security. | |
Sets the name of the title for a document that appears in the Title field in the Properties of the exported Excel document. | |
Indicates whether to use compression on exporting to an Xlsx file. |