2

我是JasperReports的新手,我想在 Web 应用程序中使用JasperViewer获得报告预览。

这是可能的还是 Web 应用程序中的任何其他查看方法(没有 PDF 和 XLSX)?

4

1 回答 1

0

You can export to html file then you can send it as output or ServletOutputStream , show it in a frame

String htmlpath="E:/JASPER/OUTPUT/test_jasper.html";
 JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
       JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
       JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
        JasperExportManager.exportReportToHtmlFile(jasperPrint,htmlpath);
        InputStream in=new FileInputStream(htmlpath);
        int len = -1;
        byte[]  byt = new byte[1024];

        ServletOutputStream outputStream = response.getOutputStream();
        while((len = in.read(byt)) != -1){
            outputStream.write(byt, 0, len);
        }
        outputStream.flush();
        outputStream.close();
于 2013-08-07T13:51:32.507 回答