Output as Excel (C#)
Set up and configure output to Microsoft® Excel™ from your reporting application. This option is useful if you want to perform custom calculations in Excel.
Note:
Excel reports, as output from Genero Report Writer, do not print at high quality. If you require high-fidelity printing, use one of the other output options, such as SVG.
Example
This code snippet shows some of the properties and methods available for an object of the
ExcelRenderer
class:// code snippet starts
String designFile = "OrderReport.4rp";
String outputFilename = "SalesList.xlsx";
FormatHandler handler = new FormatWriter(outputFilename);
ExcelRenderer renderer = new ExcelRenderer(handler);
//configuring Excel output
renderer.mergeCells = false;
renderer.mergePages = true;
renderer.outputFormat = ExcelRenderer.OutputFormat.XLSX;
FourRpLayouter report = new FourRpLayouter(designFile, renderer);
//Run the report
report.debugLevel = 9;
// some code omitted - view full source in demo
report.runFromSerializable(data);
// open the file
System.Diagnostics.Process.Start(outputFilename);
// code snippet ends
In this example:
- A
FormatHandler
object namedhandler
is defined using theFormatWriter
class, taking the name of the output file as its input. - The
mergeCells
property, when set to true, activates cell merging when the content spans several cells; when set to false, separate empty cells are created. - The
mergePages
property, when set to true, activates page merging; when set to false, separate sheets for each page are created. - The
outputFormat
property sets the output format as determined by the argument. When set toExcelRenderer.OutputFormat.XLSX
, the format is output as XLSX format (for Microsoft Excel starting with version 2007).
For the full list of properties and methods for this renderer class, refer to the Genero Report Writer .NET API documentation.