read numbers with specific format

Oct 22, 2012 at 6:16 AM

Hi all, i have xlsx file which i try to read with NPOI 2.0. Everything works great, but i have one problem. I have numbers like 139.80000000000001 where "." is separating not thousands, but decimal places. NPOI reads this number like 1,398E+16. How can i solve this problem? This number should be read like 139,80000000000001.

Oct 22, 2012 at 7:05 AM

I set cell format as STRING and read the value then and replace '.' with ','. For now it works for me, but maybe there is a better solution...

Coordinator
Oct 22, 2012 at 8:31 PM

What are you going to do? Read the number or read the string of the number? If number, you can read double value of the cell directly. The property is called CellNumericValue

Dec 19, 2012 at 9:14 PM

I have the same problems, too. Using property CellNumericValue I got some problems with Double numbers because in Italy, for example, this number:  1,510.67 is 1.510,67 (points instead of commas and viceversa). Excel spreadsheet follows this regional rule. VB.net solved this problem with 

Dim MyCultureInfo As Globalization.CultureInfo = New Globalization.CultureInfo("it-IT")

is there any similar solution in NPOI?

Coordinator
Dec 21, 2012 at 2:03 AM

This looks to be compatibility bug for European formats. I'll create a work item to fix it.

Coordinator
Dec 21, 2012 at 2:03 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.