Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue-1595. Check cell empty only after endElement is <c> #1881

Closed
wants to merge 1 commit into from

Conversation

Albert1881
Copy link
Contributor

@Albert1881 Albert1881 commented Apr 17, 2021

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>结束时,再检查单元格是否为空

@zhuangjiaju
Copy link
Collaborator

非常感谢您的PR
这个在转换的时候我加了个判断 解法稍微有点不一样
再次感谢您的PR 有好的想法可以继续提交

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants