Answer the question
In order to leave comments, you need to log in
A couple of questions about the Jasper report?
Good afternoon, I am learning to generate reports using this library.
now i have this code
public void export() throws SQLException, JRException, IOException {
String outputPath = "c:/out/report.docx";
//String inputPath = "D:\\Java\\Spring\\src\\main\\resources\\reports\\RESTQualityTask.jrxml";
String inputPath = "D:\\Java\\Spring\\src\\main\\resources\\reports\\RESTQualityTask.jrxml";
//forming raw data
List<RESTQualityTask> quality = new ArrayList<>();
// RESTQualityTask addme = postgresService.giveById(291);
// quality.add(addme);
quality = postgresService.giveall();
// put data to JR subsystem
JRBeanCollectionDataSource beanCollDataSource = new JRBeanCollectionDataSource(quality);
// Map report variable to report
Map<String, Object> paramaters = new HashMap<String, Object>();
// paramaters.put("qualityTaskId", 1234);
// get null report to JR subsystem
File reportPattern = new File(inputPath);
JasperDesign jasperDesign = JRXmlLoader.load(reportPattern);
// Compile jasper
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
// jasper fill
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, paramaters, beanCollDataSource);
//
JRDocxExporter ex = new JRDocxExporter();
ex.setExporterInput(new SimpleExporterInput(jasperPrint));
ex.setExporterOutput(new SimpleOutputStreamExporterOutput(outputPath));
ex.exportReport();
// JasperExportManager.exportReportToPdfFile(jasperPrint, outputPath);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question