Hi guys! First of all, sorry my bad english, I'll try to make it as clear as I can :)
I have an application wich needs to generate reports in PDF, HTML and XLS (Excel) formats.
When I try to generate in PDF or HTML, it works well, like this:
]
The same report, however, is shown like this when I try to generate it in XLS (Excel):
]
As you can see, there are two problems I really need to resolve as soon as possible:
1) It creates a lot of small empty rows and columns. Note that before row 15 there are about 3 useless rows. The same happens after column A, and in a lot of other places.
2) When the text in "Label 1" rows are big enough to be in more than one line, the row does not fit the lines height.
Does anybody know how to fix this? Here's the code:
I have an application wich needs to generate reports in PDF, HTML and XLS (Excel) formats.
When I try to generate in PDF or HTML, it works well, like this:
]

The same report, however, is shown like this when I try to generate it in XLS (Excel):
]

As you can see, there are two problems I really need to resolve as soon as possible:
1) It creates a lot of small empty rows and columns. Note that before row 15 there are about 3 useless rows. The same happens after column A, and in a lot of other places.
2) When the text in "Label 1" rows are big enough to be in more than one line, the row does not fit the lines height.
Does anybody know how to fix this? Here's the code:
Code: |
String nomeArq = this.getNomeArquivo(conexao.getUsuario(), param.getTipo());<br /> if (param.getTipo().equalsIgnoreCase(TipoRelatorio.PDF))<br /> JasperExportManager.exportReportToPdfFile(impressao, DIR_REPORTS<br /> + nomeArq);<br /> else if (param.getTipo().equalsIgnoreCase(TipoRelatorio.HTML))<br /> JasperExportManager.exportReportToHtmlFile(impressao, DIR_REPORTS<br /> + nomeArq);<br /> else if (param.getTipo().equalsIgnoreCase(TipoRelatorio.EXCEL)) {<br /> JRXlsExporter exporterXls = new JRXlsExporter();<br /> exporterXls.setParameter(JRExporterParameter.JASPER_PRINT, impressao); <br /> exporterXls.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,DIR_REPORTS + nomeArq); <br /> exporterXls.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE,java.lang.Boolean.TRUE); <br /> exporterXls.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE); <br /> exporterXls.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE); <br /> exporterXls.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE); <br /> exporterXls.exportReport(); <br /> }</td></tr></tbody></table><br /> <br /> <br /> The report template is XML (iReport).<br /> <br /> <br /> Thanks! |
18 Answers:
Posted on May 21, 2007 at 7:05pm
After bumping my head against this problem this is the simple way to solve:
Use iReports and make sure to vertically align all the report objects as much as possible and make sure that they are the same height. JasperReports will add extra rows and columns to cause alignment to the report specification.
Walt
Use iReports and make sure to vertically align all the report objects as much as possible and make sure that they are the same height. JasperReports will add extra rows and columns to cause alignment to the report specification.
Walt
Posted on September 3, 2007 at 1:26pm
Hi,
This problem comes from the fact that when we generate the XLS document, we do not have control over line spacing and word wrap.
Excel uses by default a line spacing that is slightly bigger then the one we have in AWT and PDF, so the same text will not fit the calculated cell height.
For better results, you can set the JRXlsAbstractExporter.IS_FONT_SIZE_FIX_ENABLED parameter to Boolean.TRUE.
This will force the use of a smaller font size so that the text content fits better in the cell.
I hope this helps.
Teodor
Post edited by: teodord, at: 2007/09/04 15:40
This problem comes from the fact that when we generate the XLS document, we do not have control over line spacing and word wrap.
Excel uses by default a line spacing that is slightly bigger then the one we have in AWT and PDF, so the same text will not fit the calculated cell height.
For better results, you can set the JRXlsAbstractExporter.IS_FONT_SIZE_FIX_ENABLED parameter to Boolean.TRUE.
This will force the use of a smaller font size so that the text content fits better in the cell.
I hope this helps.
Teodor
Post edited by: teodord, at: 2007/09/04 15:40
Posted on May 12, 2008 at 9:25am
Hi Teodor,
It seems this Excel (word wrap) is surfacing in many posts. I have seen your suggestions of setting IS_FONT_SIZE_FIX_ENABLED parameter to Boolean.TRUE. However, this might have worked for some people, but never worked for me & some others.
Can you pls advise of some alternate solution? We are using Jasper Report (2.0) in big organization production & now seems like we do not have any breakthrough. I personally think, this is major limitation in use of JasperReport.
- Rohit
It seems this Excel (word wrap) is surfacing in many posts. I have seen your suggestions of setting IS_FONT_SIZE_FIX_ENABLED parameter to Boolean.TRUE. However, this might have worked for some people, but never worked for me & some others.
Can you pls advise of some alternate solution? We are using Jasper Report (2.0) in big organization production & now seems like we do not have any breakthrough. I personally think, this is major limitation in use of JasperReport.
- Rohit
Posted on May 12, 2008 at 12:52pm
Hi,
I think if we had alternate solutions, they would have been there already.
To summarize it all: How do you control line spacing in a document format that does not allow you control line spacing?
We are open to suggestions as always.
Thank you,
Teodor
P.S. It also make me sad a little when limitations of other products are perceived as limitations of our products. But I guess this is just something we have to live with.
Post edited by: teodord, at: 2008/05/12 12:55
I think if we had alternate solutions, they would have been there already.
To summarize it all: How do you control line spacing in a document format that does not allow you control line spacing?
We are open to suggestions as always.
Thank you,
Teodor
P.S. It also make me sad a little when limitations of other products are perceived as limitations of our products. But I guess this is just something we have to live with.
Post edited by: teodord, at: 2008/05/12 12:55
Posted on May 21, 2008 at 8:27am
Hi,
Instead of trying to export the report data in Excel, I now try to export it in CSV. What i can find is there is mismatch between the coulmn and the data under it. i.e. Data set is not appearing in the column in which the coumn name is present. Please find the attachment.
In the attched file, the coulmn name SEName (column E) and column data appears under different column(column F). Same is the case with coulmn J and Column K.
Instead of trying to export the report data in Excel, I now try to export it in CSV. What i can find is there is mismatch between the coulmn and the data under it. i.e. Data set is not appearing in the column in which the coumn name is present. Please find the attachment.
In the attched file, the coulmn name SEName (column E) and column data appears under different column(column F). Same is the case with coulmn J and Column K.
Posted on May 21, 2008 at 9:27pm
Hi everyone¡¡
I'm facin a similar problen in my web app. I used to use Ireports 1.2.7 (JR same version) to export my reports to PDF or XLS files. 2 weeks ago, we decide to upgrade the tool to Ireports 2.0.2; I change all the necesary jars in my classpath; but now I'm facing a big problem:
Since that change, my xls reports are not as cool as they used to be (with my old version of IR), now it seems that my app just ignore all the sentences where I try to set the parameters to export (like: IS_WHITE_PAGE_BACKGROUND) so my reports looks like the image attached.
Here is a part of my code:
JasperPrint jasperPrint = JasperFillManager.fillReport(new FileInputStream(reportFile), parameters, conn);
JRXlsExporter xlsExporter = new JRXlsExporter();
xlsExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
xlsExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outFileName);
xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
xlsExporter.exportReport();
What am I doing wrong??
Why the export parameters are ignore with the upgrade??
Pleaseeeee... I relly need help... I'm desperate...
Thanks a lot...
Marianela
Post edited by: marianela, at: 2008/05/21 21:29
Post edited by: marianela, at: 2008/05/21 21:31
I'm facin a similar problen in my web app. I used to use Ireports 1.2.7 (JR same version) to export my reports to PDF or XLS files. 2 weeks ago, we decide to upgrade the tool to Ireports 2.0.2; I change all the necesary jars in my classpath; but now I'm facing a big problem:
Since that change, my xls reports are not as cool as they used to be (with my old version of IR), now it seems that my app just ignore all the sentences where I try to set the parameters to export (like: IS_WHITE_PAGE_BACKGROUND) so my reports looks like the image attached.
Here is a part of my code:
JasperPrint jasperPrint = JasperFillManager.fillReport(new FileInputStream(reportFile), parameters, conn);
JRXlsExporter xlsExporter = new JRXlsExporter();
xlsExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
xlsExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outFileName);
xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
xlsExporter.setParameter(JRXlsAbstractExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
xlsExporter.exportReport();
What am I doing wrong??
Why the export parameters are ignore with the upgrade??
Pleaseeeee... I relly need help... I'm desperate...
Thanks a lot...
Marianela
Post edited by: marianela, at: 2008/05/21 21:29
Post edited by: marianela, at: 2008/05/21 21:31
Posted on June 3, 2008 at 4:49pm
marianela wrote:
I tested IS_WHITE_PAGE_BACKGROUND in JasperReports 2.0.2 and it worked fine.
If you want help, post enough information (i.e. sample JRXML, relevant Java code, XLS output) such that other people can reproduce your problem and identify its cause.
Regards,
Lucian
now it seems that my app just ignore all the sentences where I try to set the parameters to export (like: IS_WHITE_PAGE_BACKGROUND) |
I tested IS_WHITE_PAGE_BACKGROUND in JasperReports 2.0.2 and it worked fine.
If you want help, post enough information (i.e. sample JRXML, relevant Java code, XLS output) such that other people can reproduce your problem and identify its cause.
Regards,
Lucian
Posted on November 25, 2014 at 2:23pm
Please check this link - what worked for me.
https://community.jaspersoft.com/questions/518408/one-cell-column-excel