Jasper Reports Excel output

给你一囗甜甜゛ 提交于 2020-06-24 07:39:48

问题


I need to generate a report in Excel format using Jasperreports. I am using iReports 3.7.0 The reports gets generated with no issues except the size of empty cells.

alt text

Can somebody please tell how to avoid the highlighted cell being enlarged. Also the normal cells are also a little larger than their content.


回答1:


Also,I would say stick to basics when you need to export Japser to XLS. I mean no graphics, and more.

The above solution is good for generating XLS from iReport.

If you would like to generate XLS thru program; use the following code

exporter = new JRXlsExporter();
exporter.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.TRUE);



回答2:


I got the answer. Thought of sharing it with others. Below is the setting.

alt text




回答3:


Also - if you're deploying to jasperserver you can set the custom properties within the report. (iReport doesn't do this automatically)

In the properties of the main report element add:

net.sf.jasperreports.export.xls.collapse.row.span
net.sf.jasperreports.export.xls.remove.empty.space.between.columns
net.sf.jasperreports.export.xls.remove.empty.space.between.rows

and set them all to true



来源:https://stackoverflow.com/questions/1881316/jasper-reports-excel-output

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