Bug 61858 - Getting double value from the method "cell" of interface "SheetContentsHandler" of "XSSFSheetXMLHandler" class
Summary: Getting double value from the method "cell" of interface "SheetContentsHandle...
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2017-12-05 12:57 UTC by Phaneeswar
Modified: 2021-10-10 16:07 UTC (History)
0 users

Changes that give the double value of the cell to output (6.37 KB, patch)
2017-12-05 12:57 UTC, Phaneeswar
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Phaneeswar 2017-12-05 12:57:44 UTC
Created attachment 35586 [details]
Changes that give the double value of the cell to output

There are two things I think will be helpful with this patch:
1) When in Excel the cell date format and the system date format are same, the underlying cell format is not considered when reading and the value.Value is generated based on the local system date format where we are reading the Excel file.In such a case if I get the cell value in the string format, there is nothing much I can do to get the value in the format which I required as output.This can be possible If I have the double value of that cell.
2) When the cell is Number say with format(5,000).If I get the value as String,
I will get it as 5,000. If I want to convert it into a Double by parsing the value 5,000 It will throw an error. If I have a double value in this case things can be done easily.
Comment 1 PJ Fanning 2017-12-05 22:14:19 UTC
Thanks Phaneeswar for the proposed patch.
It does modify a public API (the cell method) and this is not something that we don't do without deprecating the existing method. The replacement method can be added and the deprecated version can call the replacement version.

It's not generally required but I personally much prefer to review patches added via github - see https://github.com/apache/poi

My view on the patch, as is, is that it may not be necessary. If you look at the XLSX2CSV example in Poi, you will see that you can provide your own DataFormatter and with a custom DataFormatter, you could omit the number formatting and just represent the numbers in plain format.

Comment 2 Dominik Stadler 2017-12-26 09:58:21 UTC
Please provide an updated patch or state if the proposed workaround is sufficient for you.

Please also note that producing a minimal patch without whitespace-changes is preferred as it minimizes the work needed to review the patch and thus increases the chances of having it integrated.
Comment 3 Phaneeswar 2017-12-27 06:06:49 UTC
Thanks for the example it really helps for Number format case.But the provided work around would be sufficient if I want to show output as 5,000. But what if I want to show the value as 5000.00. Having only the string value 5,000 known to me.

And I think for handling Date format issue still we need to know the double value.

By which for both cases the change same.So I don't think an updated patch is required.
Comment 4 Mark Murphy 2018-04-20 15:24:58 UTC
Sorry, wrong bug.
Comment 5 PJ Fanning 2021-10-10 16:07:06 UTC
I think this issue reached a stage where it was decided the patch was not needed