How to setup print excel files in jasper reports

百般思念 提交于 2019-12-13 04:45:54

问题


i have problem with my excel when i print preview the files after i export the report into excel. How to setup the files when i print the files, it will automatic fix the size according the A4 paper?.


回答1:


  HSSFPrintSetup printSetup = sheet.getPrintSetup();
    sheet.getPrintSetup().setFitWidth((short) 1);
    sheet.getPrintSetup().setFitHeight((short) 0);
    sheet.setAutobreaks(true);
    printSetup.setLandscape(true);

    HSSFFooter footer = sheet.getFooter();
    footer.setCenter("Page " + HSSFFooter.page() + " of "+ HSSFFooter.numPages());



回答2:


I had this problem as well: Exporting to Excel and opening a Print preview did not show A4 but Letter, despite the report page format being configured as A4 (that is 842 * 595 pixels).

During Excel export, Jasper calculates and sets the paper size in the private final short getSuitablePaperSize() method of net.sf.jasperreports.engine.export.JRXlsExporter (as of JasperReports 6.2.0).

The calculation did not work correctly because the JRParameter.IS_IGNORE_PAGINATION flag was turned on. With this flag, Jasper considers the entire report as one single page, so page size and page width are not anymore the same as defined in the report's page format.

Leaving JRParameter.IS_IGNORE_PAGINATION at false produced the correct print preview (in A4).



来源:https://stackoverflow.com/questions/10814292/how-to-setup-print-excel-files-in-jasper-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!