DDwrt1002019-09-19 12:47:45
DDwrt100, 2019-09-19 12:47:45

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));
      //  JasperExportManager.exportReportToPdfFile(jasperPrint, outputPath);


The report is generated but there are some difficulties
1) If I pull one record, then the report is filled correctly, if I pull several records, the first page is full, and all other pages will be empty. What am I doing wrong?
2) Now for accessing report files and uploading there are full paths in the file system, how can I make the path short?
3) What methods can I give a file to the Web? What should I use?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question