Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

Commented Unassigned: NPOI interprets date formats differently [13398]

$
0
0
I have an _xlsx_ file with several dates.
One cell appears in Excel 2007 (configured as Spanish, Spain, international) as "01/02/2003 4:05" (that is 1st February 2003). The cell format appears as "dd/mm/aaaa h:mm" in Excel. NPOI gets "2/1/03 4:05".
What appears as "01/12/2001" is read by NPOI as "12/1/01". The cell format is "*14/03/2001" in Excel.
What appears as "23:05:00" is read by NPOI as "11:05:00 ". The cell format is "*13:30:55" in Excel.

The code I use to read the file is:
```
DataFormatter dataFormatter= new DataFormatter(CultureInfo.CurrentCulture); // es-ES
// ...
object cellValue= dataFormatter.FormatCellValue(ijCell);
```

In some cases, I see that NPOI is applying the predefined formats from _NPOI.SS.UserModel.BuiltinFormats_, but they seem not to match what Spanish Excel does.

Is there a way to make NPOI use the same format as Spanish Excel?
Comments: ** Comment from web user: bastianonm **

I'm having the same issue and it's quite bad situation..
I've to convert the excel in txt and the dates are completly wrong

These are example of conversion:

20/06/2012 -> 6/20/12
05/07/2012 -> 7/5/12

Sometimes it makes impossible to understand the correct date.

the cell.CellStyle.DataFormat is 14
the excel format is DD/MM/YYYY en-UK

If there are no ways to get the correct vaue, I'm obligated to move to other excel library


Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>