开发者

Can we print only a certain page in a multi page jasper report?

开发者 https://www.devze.com 2023-01-04 02:20 出处:网络
Is there a way to print only specific pages in jasper. I need it for pagination purpose. ex: if I have 20 pages, i should be able to get jasper to generate one page report at a time. Can i pass the p

Is there a way to print only specific pages in jasper. I need it for pagination purpose.

ex: if I have 20 pages, i should be able to get jasper to generate one page report at a time. Can i pass the page numbe开发者_如何学JAVAr as a param?


Answering my own question,

Yes it is possible.. atleast in case of HTML and csv reports. The code that does this is below.

JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(3));
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"d://ReportResult//FinalReportResult.html");

Once this is set, just do a

exporter.exportReport();

In the above case, page number 4, i.e, index 3 is exported to the HTML file.

0

精彩评论

暂无评论...
验证码 换一张
取 消