Search before asking
Motivation
This is about failing with a useful error, not about supporting more cell types.
A cell whose t attribute is not one of s, str, inlineStr, e, b, n aborts the whole read with an error that names neither the cell nor the attribute:
java.lang.IllegalArgumentException: Type can not be null
at org.apache.fesod.sheet.metadata.data.ReadCellData.<init>(ReadCellData.java:78)
at org.apache.fesod.sheet.analysis.v07.handlers.CellTagHandler.startElement(CellTagHandler.java:63)
Repro:
Any xlsx sheet that contains e.g. <c r="A1" t="d"><v>2024-05-01T00:00:00</v></c> (or t="anything")
Cause:
In CellDataTypeEnum.buildFromCellType, a missing t attribute is handled - it returns EMPTY. But when t is present with a value that isn't in the map, the lookup returns null and nothing checks for it. That null then trips the ReadCellData constructor, which is where the confusing exception comes from.
Solution
Keep failing, but say what happened. In CellTagHandler.startElement:
String cellType = attributes.getValue(ExcelXmlConstants.ATTRIBUTE_T);
CellDataTypeEnum type = CellDataTypeEnum.buildFromCellType(cellType);
if (type == null) {
throw new ExcelAnalysisException("Unsupported cell type '" + cellType + "'");
}
Alternatives
Fall back to DIRECT_STRING when the type is null
Anything else?
No response
Are you willing to submit a PR?
Search before asking
Motivation
This is about failing with a useful error, not about supporting more cell types.
A cell whose
tattribute is not one ofs,str,inlineStr,e,b,naborts the whole read with an error that names neither the cell nor the attribute:Repro:
Any xlsx sheet that contains e.g.
<c r="A1" t="d"><v>2024-05-01T00:00:00</v></c>(ort="anything")Cause:
In
CellDataTypeEnum.buildFromCellType, a missingtattribute is handled - it returnsEMPTY. But whentis present with a value that isn't in the map, the lookup returnsnulland nothing checks for it. That null then trips theReadCellDataconstructor, which is where the confusing exception comes from.Solution
Keep failing, but say what happened. In
CellTagHandler.startElement:Alternatives
Fall back to
DIRECT_STRINGwhen the type isnullAnything else?
No response
Are you willing to submit a PR?