This sample project shows how to render and export a report to various formats. You can use more than 15 formats for exporting, each of them can be set up.

First, load the report and add a Demo database to it. After this is done, render the report:
...

StiXmlDatabase xmlDatabase = new StiXmlDatabase("Demo", demoDir + "Demo.xsd", demoDir + "Demo.xml");
StiReport renderReport = StiSerializeManager.deserializeReport(new File("Reports/SimpleList.mrt"));
renderReport.getDictionary().getDatabases().add(xmlDatabase);
renderReport.render();

...

Then, depending on format, you can export the report with default export settings:
...

outputStream = new FileOutputStream(stiFileChooser.getFile());
switch (format) {
	case Pdf:
		StiExportManager.exportPdf(report, outputStream);
		break;
	
	case Xps:
		StiExportManager.exportXps(report, outputStream);
		break;
	
	case Html:
		StiExportManager.exportHtml(report, outputStream);
		break;
	
	case Text:
		StiExportManager.exportText(report, outputStream);
		break;
	
	case Rtf:
		StiExportManager.exportRtf(report, outputStream);
		break;
	
	case Word2007:
		StiExportManager.exportWord2007(report, outputStream);
		break;
	
	case Excel:
		StiExportManager.exportExcel(report, outputStream);
		break;
	
	case ExcelXml:
		StiExportManager.exportExcelXml(report, outputStream);
		break;
	
	case Excel2007:
		StiExportManager.exportExcel2007(report, outputStream);
		break;
	
	case Csv:
		StiExportManager.exportCsv(report, outputStream);
		break;
	
	case Xml:
		StiExportManager.exportXml(report, outputStream);
		break;
	
	case Sylk:
		StiExportManager.exportSylk(report, outputStream);
		break;
	
	case ImageBmp:
		StiExportManager.exportImageBmp(report, outputStream);
		break;
	
	case ImageJpeg:
		StiExportManager.exportImageJpeg(report, outputStream);
		break;
	
	case ImagePcx:
		StiExportManager.exportImagePcx(report, outputStream);
		break;
	
	case ImagePng:
		StiExportManager.exportImagePng(report, outputStream);
		break;
	
	case ImageSvg:
		StiExportManager.exportImageSvg(report, outputStream);
		break;
	
	case ImageSvgz:
		StiExportManager.exportImageSvgz(report, outputStream);
		break;
}

...

You can also customize export settings, for example for the export to PDF:
...

StiPdfExportSettings pdfExportSettings = new StiPdfExportSettings();
pdfExportSettings.setAllowEditable(StiPdfAllowEditable.Yes);
pdfExportSettings.setPdfACompliance(true);
pdfExportSettings.setEmbeddedFonts(true);
pdfExportSettings.setPasswordInputUser("pass");
StiExportManager.exportPdf(report, pdfExportSettings, outputStream);

...

In the screenshot below you can see the result of the sample code:

Exporting a Report from Code

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.