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
Created attachment 37298 [details] Test project
(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.
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?
XML Entities are seriously frowned on these days.
I added revisions - https://github.com/apache/poi/commit/20540f3c69eb1c48a0ebbd8c49bcfe6ea6f3e165 and https://github.com/apache/poi/commit/26c2049147c488edb04bbd099ea65ef494a86c72