|
|
| Re: Formatting numbers in excel export [message #1857683 is a reply to message #1857678] |
Tue, 21 February 2023 07:46   |
Uwe Peuker Messages: 13 Registered: September 2016 |
Junior Member |
|
|
Thanks for the response, but I think this is not my problem.
I have the value as Number for the exportCell-function. And it will be stored in the excel file.
But my aim is to set a formatting cell style for the number columns in excel.
In line 231-232 in PoiExcelExporter the CellStyle is created and applied. But it misses the data format for every value except Date and Calendar.
So my idea would be to expand the getDataFormatString function more abstract and to deliver a common "data format" and not only a "date format". Overwriting the function in a superclass does not work because of the restriction in lines 216-219 in PoiExcelExporter. Possibly this check should be removed to call it for every type!? I see the problem of the default return value of this function!
Another solution could be to extend the function with a cell format parameter? So the solution to search for it inside of exportCell could be replaced.
Added a sample, which would help in my case without breaking the previous behavior .
[Updated on: Tue, 21 February 2023 13:51] Report message to a moderator
|
|
|
|
|
|
| Re: Formatting numbers in excel export [message #1857713 is a reply to message #1857695] |
Wed, 22 February 2023 07:57   |
Uwe Peuker Messages: 13 Registered: September 2016 |
Junior Member |
|
|
Thanks, works fine.
But there is a little side effect which could be disturb other existing users:
If you don't overwrite the geteDataFormatString function and you don't register formats mit related labels, every number in the excel table will be formatted as date.
I would see the following extensions:
- Adding additional ExportConfigAttributes like LONG_FORMAT and DOUBLE_FORMAT and look for them and not for DATE_FORMAT in the case of the number types
- Do not look for the format for String and Boolean values
- Possibly expand Integer with Long and(or Double with Float (I know there are more!?)
Note: Possibly Integer could be ignored too? As I know excel does not support formats like "0.00 kg"?
[Updated on: Wed, 22 February 2023 08:17] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03084 seconds