Fix issue-1595. Check cell empty only after endElement is <c> #1881
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix excel中包含高管关键词解析失败 #1595.
Bug Analysis:
报错位置:com\alibaba\excel\analysis\v07\handlers\AbstractCellValueTagHandler.java
报错原因:
xlsx 中存在这样一个单元格:
<c r="D24" t="inlineStr"><is><r><t xml:space="preserve"></t></r><r><rPr><rFont val="Calibri"/><b val="false"/><i val="false"/><strike val="false"/><color rgb="FFFF0000"/><sz val="11"/><u val="none"/></rPr><t xml:space="preserve">OLAY</t></r><r><t xml:space="preserve">精华身体乳,按压设计,刚挤出来感觉会有点厚重,但是涂在身上好推开,吸收也很快。</t></r></is></c>
读取
<t xml:space="preserve"></t>
时,默认cell类型为STRING
,由于获取内容为空,tempCellData.checkEmpty();
将该单元格类型转为EMPTY
;然后读取
<t xml:space="preserve">OLAY</t>
时,由于单元格类型转为EMPTY
,但是读入数据为OLAY
,在将它转换成数字类型时报错new BigDecimal(tempData.toString())
修复方法:
删除
AbstractCellValueTagHandler
中对每个tag检查是否为空;将检测移到AbstractXlsxTagHandler
,当单元格结束时,即处理<c>
结束时,再检查单元格是否为空