Код: Выделить всё
public static void exportToOds(List jasperPrints, ByteArrayOutputStream output) {
try (ByteArrayOutputStream outputStream = output) {
JROdsExporter exporter = new JROdsExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrints));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream));
SimpleOdsReportConfiguration configuration = new SimpleOdsReportConfiguration();
configuration.setOnePagePerSheet(true);
exporter.setConfiguration(configuration);
exporter.exportReport();
} catch (Exception e) {
throw new RuntimeException("Error exporting report to ODS", e);
}
}
Код: Выделить всё
public void fill(UUID templateId, List jasperPrints, StorageMtsData data) {
List sheet = data.getStorageMtsDataSheet();
JasperReport jasperReport = compileReport(String.format("report/%s/StorageMTCMainReport.jrxml", templateId));
JasperReport jasperSubReport = compileReport(String.format("report/%s/StorageMTCSubReport.jrxml", templateId));
JasperReport jasperSubSubReport = compileReport(String.format(
"report/%s/StorageMTCSubSubTAReport.jrxml",
templateId
));
JRBeanCollectionDataSource mainDataSource = new JRBeanCollectionDataSource(sheet);
Map params = new HashMap();
params.put("SUBREPORT_PATH", jasperSubReport);
params.put("SUBREPORT_SUBREPORT_PATH", jasperSubSubReport);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, mainDataSource);
jasperPrints.add(jasperPrint);
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... rated-in-j