Bug 63340 - getCellType throws error on cells formatted as date
Summary: getCellType throws error on cells formatted as date
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.0.0-FINAL
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-11 13:17 UTC by andrin.meier
Modified: 2019-04-11 19:33 UTC (History)
0 users



Attachments
Testdata (22.73 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2019-04-11 16:55 UTC, andrin.meier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description andrin.meier 2019-04-11 13:17:03 UTC
I receive the following error when calling Cell.getCellType on cells formatted as date. The input is an .xlsx file.

org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: string value 'd' is not a valid enumeration value for ST_CellType in namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
	at org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.set_text(JavaStringEnumerationHolderEx.java:40)
	at org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1180)
	at org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1319)
	at org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.getEnumValue(JavaStringEnumerationHolderEx.java:60)
	at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellImpl.getT(Unknown Source)
	at org.apache.poi.xssf.usermodel.XSSFCell.getBaseCellType(XSSFCell.java:719)
	at org.apache.poi.xssf.usermodel.XSSFCell.getCellType(XSSFCell.java:681)
	at org.apache.poi.xssf.usermodel.XSSFCell.getDateCellValue(XSSFCell.java:755)

I updated to the latest 4.1 version but the error persists.
Comment 1 PJ Fanning 2019-04-11 16:12:40 UTC
Can you attach a spreadsheet that demonstrates the issue?
Comment 2 Greg Woolsey 2019-04-11 16:38:03 UTC
ST_CellType="d" was added to the OOXML standard in ECMA-376:2012.  POI doesn't support strict mode yet, or the later extensions.  POI OOXML currently is based on the 2006 schemas, which did not include "d" (ISO date) as a value type.
Comment 3 andrin.meier 2019-04-11 16:55:14 UTC
Created attachment 36520 [details]
Testdata
Comment 4 andrin.meier 2019-04-11 16:55:52 UTC
Is there a workaround?
Comment 5 PJ Fanning 2019-04-11 19:33:22 UTC
The POI streaming support does not use the generated classes based on the OOXML schemas - the plus is that it can parse your file but the minus is that the feature support is a lot less.

https://github.com/pjfanning/excel-streaming-reader-sample -- I used this code to parse your file