Bug 64508 - java.lang.NumberFormatException: For input string: ""
Summary: java.lang.NumberFormatException: For input string: ""
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.1.2-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-09 16:04 UTC by Kovi
Modified: 2020-07-15 20:59 UTC (History)
0 users



Attachments
Test project (5.66 KB, application/x-7z-compressed)
2020-06-09 16:06 UTC, Kovi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kovi 2020-06-09 16:04:51 UTC
I'm using POI 4.1.2 on Ubuntu 20.04. The same problem occurs on POI 3.10.1, 3.17. These are the three version I tried.
When I try to run the attached program I get:
java.lang.NumberFormatException: For input string: ""
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:592)
        at java.lang.Integer.parseInt(Integer.java:615)
        at org.apache.poi.xssf.usermodel.XSSFCell.getRichStringCellValue(XSSFCell.java:377)
        at org.apache.poi.xssf.usermodel.XSSFCell.getStringCellValue(XSSFCell.java:342)
        at com.kovi.poitest.Test.main(Test.java:26)

What I could see is that the problem occurs in org.apache.poi.xssf.usermodel.getRichStringCellValue() where _cell.isSetV() returns true, but in fact should be false. I think this is wrong because isSetV() only checks if the element v is present. In example Excel file E2 is:
<c r="E2" s="4" t="s"><v/>
</c>
so there is a v element, but it is empty.
Test project is Maven based and you can run it from build folder: java -cp "poitest-1.0.0.jar:lib/*" com.kovi.poitest.Test TEST.xlsx
Comment 1 Kovi 2020-06-09 16:06:22 UTC
Created attachment 37298 [details]
Test project
Comment 2 chenlin 2020-07-14 08:18:06 UTC
(In reply to Kovi from comment #1)
> 创建了附件37298  [详细信息] 
> 测试项目

Test cases provided by you 
Add a condition in the place where you are marking: 
if (_cell.isSetV() && _cell.getV()! ="") { 
                        int idx = Integer.parseInt(_cell.getV()); 
                        rt = new XSSFRichTextString(_sharedStringSource.getEntryAt(idx)); 
                    } 
It seems to solve the problem and will not cause the original logic to be damaged.
Comment 3 PJ Fanning 2020-07-15 20:51:58 UTC
That test.xlsx in the 7z file seems corrupt. Gives this error:

<![CDATA[[Fatal Error] :1:1: JAXP00010001: The parser has encountered more than "1" entity expansions in this document; this is the limit imposed by the JDK.
]]

What created this file?
Comment 4 PJ Fanning 2020-07-15 20:52:53 UTC
XML Entities are seriously frowned on these days.