gettingstartedwithjasperreports
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| gettingstartedwithjasperreports [2022/01/05 19:50] – [MIStudio SimpleReport Project] wikiadmin | gettingstartedwithjasperreports [2022/01/05 20:09] (current) – [Generate a Spreadsheet from SimpleReport] wikiadmin | ||
|---|---|---|---|
| Line 298: | Line 298: | ||
| That's the end of this basic Tutorial. You can also generate other report types from this same SimpleReport.jasper file (see code examples below). | That's the end of this basic Tutorial. You can also generate other report types from this same SimpleReport.jasper file (see code examples below). | ||
| - | ===Generate | + | ===Generate |
| - | Instead of generating a PDF you can make an xls or xlsx report (excel spreadsheets). | + | Instead of generating a PDF you can make an xls or xlsx report (excel spreadsheets), or a csv file. |
| To make an xls spreadsheet, | To make an xls spreadsheet, | ||
| Line 339: | Line 339: | ||
| <code javascript> | <code javascript> | ||
| + | //Script to run SimpleReport.jasper as an XLSX Excel Spreadsheet | ||
| + | var HashMap = Java.type(" | ||
| + | var FileInputStream = Java.type(" | ||
| + | var JasperPrint = Java.type(" | ||
| + | var JasperFillManager = Java.type(" | ||
| + | var JRXlsxExporter = Java.type(" | ||
| + | var SimpleOutputStreamExporterOutput = Java.type(" | ||
| + | var SimpleExporterInput = Java.type(" | ||
| + | |||
| + | compiledReport=" | ||
| + | outputName = " | ||
| + | |||
| + | try { | ||
| + | reportStream = new FileInputStream(compiledReport); | ||
| + | parameters = new HashMap(); //empty hashmap | ||
| + | jasperPrint = JasperFillManager.fillReport( reportStream , parameters); | ||
| + | xlxsExporter = new JRXlsxExporter(); | ||
| + | xlxsExporter.setExporterInput(new SimpleExporterInput(jasperPrint)); | ||
| + | xlxsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputName)); | ||
| + | xlxsExporter.exportReport(); | ||
| + | |||
| + | | ||
| + | } catch (e) { | ||
| + | print(" | ||
| + | print(e); | ||
| + | | ||
| + | } | ||
| </ | </ | ||
| Line 345: | Line 372: | ||
| <code javascript> | <code javascript> | ||
| + | //Script to run SimpleReport.jasper to generate a CSV file | ||
| + | |||
| + | var HashMap = Java.type(" | ||
| + | var FileInputStream = Java.type(" | ||
| + | var JasperPrint = Java.type(" | ||
| + | var JasperFillManager = Java.type(" | ||
| + | var JRCsvExporter = Java.type(" | ||
| + | var SimpleCsvExporterConfiguration = Java.type(" | ||
| + | var SimpleWriterExporterOutput = Java.type(" | ||
| + | var SimpleExporterInput = Java.type(" | ||
| + | |||
| + | compiledReport=" | ||
| + | outputName = " | ||
| + | |||
| + | try { | ||
| + | reportStream = new FileInputStream(compiledReport); | ||
| + | parameters = new HashMap(); //empty hashmap | ||
| + | parameters.put(" | ||
| + | jasperPrint = JasperFillManager.fillReport( reportStream , parameters); | ||
| + | csvExporter = new JRCsvExporter(); | ||
| + | csvExporter.setExporterInput(new SimpleExporterInput(jasperPrint)); | ||
| + | csvExporter.setExporterOutput(new SimpleWriterExporterOutput(outputName)); | ||
| + | csvConfiguration = new SimpleCsvExporterConfiguration(); | ||
| + | csvConfiguration.setWriteBOM(true); | ||
| + | csvConfiguration.setRecordDelimiter(" | ||
| + | csvExporter.setConfiguration(csvConfiguration); | ||
| + | csvExporter.exportReport(); | ||
| + | | ||
| + | } catch (e) { | ||
| + | print(" | ||
| + | print(e); | ||
| + | | ||
| + | } | ||
| + | |||
| + | |||
| </ | </ | ||
gettingstartedwithjasperreports.1641430250.txt.gz · Last modified: by wikiadmin
