ClassCastException in Excel emitter
Discussed in https://github.com/eclipse/birt/discussions/946
Originally posted by jochenberger April 19, 2022 Hi there,
I'm getting the following exception when trying to create an XLSX report. The report contains an HTML table, maybe that's a problem. I'm using Birt 4.9 BTW.
...
Caused by: java.lang.ClassCastException: class org.eclipse.birt.report.engine.content.impl.ContainerContent cannot be cast to class org.eclipse.birt.report.engine.content.impl.CellContent (org.eclipse.birt.report.engine.content.impl.ContainerContent and org.eclipse.birt.report.engine.content.impl.CellContent are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @31f04847)
at uk.co.spudsoft.birt.emitters.excel.handlers.AbstractRealTableCellHandler.startTable(AbstractRealTableCellHandler.java:188)
at uk.co.spudsoft.birt.emitters.excel.ExcelEmitter.startTable(ExcelEmitter.java:297)
```</div>
Can you provide a report design with which one can reproduce the error?
https://github.com/SerNet/verinice/blob/1.23.1/sernet.gs.server/WebContent/WEB-INF/reportDeposit/bp_riskmatrix.rptdesign
https://github.com/eclipse/birt/discussions/946#discussioncomment-2660885 contains a repro file that does not use a custon data source
@jochenberger, I have actually made some small tests with that file. I have not found the root of the problem yet but I do not think that it is not a matter of a simple programming error. Last I looked at it my investigation ended at: uk.co.spudsoft.birt.emitters.excel.handlers.StringCellHandler.visit() which was called with an ITableContent .
I have not worked with the Spudsoft emitter at all. We have no reports that uses it.
I do not know when I will have time to take another look at it, it may take another couple of weeks
I'm not in a hurry. Thanks for your efforts so far. If you need anything or want me to do some tests, just let me know.
I think we can close this issue according to the comment of #946 table-tag on XLS/XLSX-cell-level not supported. And I see no way how should it work.
Because the idea of spudsoft is generate the excel sheet on the largest given table (most columns) based on report design file and set all given columns and contents of this excel-layout. Now the cell content will be created danymicaly which is fine for PDF and HTML but not for excel. Spudsoft has defined the matrix of the sheet and now it should add new table definitions with partial differet column counts.
The best way woul be if excel is relevant to add the layout of the (cuurently) dynamic tables to the report layout (e.g. 4 single tables). So the full control is given and excel with spudsoft will work. Please be aware you have a special layout which will need time to get a good excel report layout.
But from my point of view it is not a bug it works like designed.
I'd prefer a more helpful error message though. A ClassCastException looks as if the library is doing something wrong, not the user. 🙂
I'd prefer a more helpful error message though. A ClassCastException looks as if the library is doing something wrong, not the user. 🙂
Jochen, can you make a patch that catches this and makes a better error message?