Reading in an Excel file with custom number format is treated as a timestamp instead of number. Attached example file will show the bug. Number format is set to D-##### for German zip code but returned as a timestamp.
Hi,
Hi there,
this is the code:
…
Iterator allRows = sheet.getCells().getRowEnumerator();
while(allRows.hasNext()) {
Row row = (Row)allRows.next();
…
Cell cell = row.get(i);
if(cell.getType() == CellValueType.IS_DATE_TIME) {
//entering this condition on custom formatted cells
Date date = cell.getDateTimeValue().toDate();
…
} else …
Regards,
Steffen
Hi Steffen,
Thanks for your posting and using Aspose.Cells.
We were able to observe this issue after running the following code using your sample file with the latest version: Aspose.Cells
for Java v8.1.0.2. We found that Aspose.Cells is detecting the number as date time.
We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.
This issue has been logged CELLSJAVA-40862.
Java
Workbook workbook = new Workbook(“test.xlsx”);
Worksheet ws = workbook.getWorksheets().get(0);
Cells cells = ws.getCells();
System.out.println(cells.get(“A1”).getStringValue());
System.out.println(cells.get(“A1”).getDisplayStringValue());
Cell cell = cells.get(“A1”);
System.out.println(cell.getType() == CellValueType.IS_DATE_TIME);
D-12345
D-12345
true
Hi,
works perfectly! Thanks for the great job.
Hi,
The issues you have found earlier (filed as CELLSJAVA-40862) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.