Summary: | Hyperlink parser is overly strict causing document open to fail for doc which works in other tools | ||
---|---|---|---|
Product: | POI | Reporter: | Tom Morris <tfmorris> |
Component: | XSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | gavr145 |
Priority: | P2 | ||
Version: | 3.11-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: | Failing document |
Description
Tom Morris
2012-02-20 18:38:29 UTC
Have you tried with POI 3.8 beta 5? The behavior is the same with 3.8b5. It doesn't look like the code has changed at all in this area. Which bug fix did you think was in beta 5 that would improve this? The user who provided the file reports that it was created in the following manner: "The file was created by dumping an mSQL database (by Hughes) to an HTML page using a simple table. The HTML table was dragged and dropped to Excel 2010." Should be fixed in r1292295, junit added. > (As an aside, it > would be much more polite to your callers to use a checked exception so they'd > know it was coming and be able to handle it.) > The only checked exception that can be thrown when constructing XSSFWorkbook is IOException but it is not the case. So we stay with IllegalStateException. Yegor Thanks for the quick fix. I verified the fix in SVN and it works great. Is there a projected date when 3.8 will be released? I looked at the web site and checked the dev list mail archive and wasn't able to figure out what the schedule is. Thanks again! >
> Is there a projected date when 3.8 will be released? I looked at the web site
> and checked the dev list mail archive and wasn't able to figure out what the
> schedule is.
>
I was planning to roll 3.8-beta6 in March and then release 3.8-final sometime in mid or late April, but there is a good chance we will skip beta6 and release 3.8-final within a month.
Stay on poi-dev, the release date will be discussed.
Yegor
I'm reopening the bug (having the same with 3.11): java.lang.Class - java.lang.IllegalStateException: A sheet hyperlink must either have a location, or a relationship. Found: <xml-fragment ref="B3" display="Something" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"/> at org.apache.poi.xssf.usermodel.XSSFHyperlink.<init>(XSSFHyperlink.java:72) at org.apache.poi.xssf.usermodel.XSSFSheet.initHyperlinks(XSSFSheet.java:205) at org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:159) at org.apache.poi.xssf.usermodel.XSSFSheet.onDocumentRead(XSSFSheet.java:134) at org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead(XSSFWorkbook.java:235) at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190) at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:182) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:63) at org.is.jxlpoi.JXLPOIWorkbook.getWorkbook(JXLPOIWorkbook.java:80) Please provide a sample document (unless it can be reproduced with the one attached here as well). Yes, it is reproducable with the attached document (mfb_a.xlsx): java.lang.IllegalStateException: A sheet hyperlink must either have a location, or a relationship. Found: <xml-fragment ref="A1" tooltip="Sort on ID" display="ID" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"/> at org.apache.poi.xssf.usermodel.XSSFHyperlink.<init>(XSSFHyperlink.java:72) at org.apache.poi.xssf.usermodel.XSSFSheet.initHyperlinks(XSSFSheet.java:205) at org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:159) at org.apache.poi.xssf.usermodel.XSSFSheet.onDocumentRead(XSSFSheet.java:134) at org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead(XSSFWorkbook.java:235) at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190) at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:182) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:63) I mean, with the file attached by the previous reporter, the originally submitted file. Hm, there is an active unit-test at TestXSSFHyperlink.test52716() which verifies that this file can still be read correctly. I also tried with WorkbookFactory and it did also work fine. Are you sure you are using the latest version of POI? If so, please share your code to see if there is any difference in how you load the workbook. Hi Dominik, This particular exception occurs with poi-3.11-FINAL as noted above, i.e. the latest stable version (we were not thinking to put beta to production yet and haven't tested the beta yet), not the latest version from svn. The WorkbookFactory is used: FileInputStream fis = new FileInputStream("C:/AAA/mfb_a.xlsx"); Workbook temp = WorkbookFactory.create(fis); with both your file (I just double-checked it) and our file, with the same exception. Due to this thread, I thought that this issue was fixed long before 3.11-FINAL. Please let me know if you want more information. Thanks It is fixed since somewhere around 2012 as far as I see. So if I look at line "72" of class XSSFHyperlink which is referenced in the exception stacktrace that you posted, I see that since the fix in 2012 the line 72 is not executable code, but rather a bracket ("}"), so I conclude that if you are really seeing the same stacktrace, then you are likely still having some outdated version of POI in use somewhere, i.e. by having an old jar-file in the classpath. In fact the error text that is shown in the exception does not even exist any more in all of POI's code since 2012, so I cannot see how it could even appear in a current version of POI. If you really can reproduce this problem with version 3.11 of POI, then please post the actual stacktrace that you get so we can see what the actual error message is. The "A sheet hyperlink must either ..." is very unlikely to still be possible with 3.11 and newer... Ok, here is my fault! I found a dependency from another imported project which used poi-3.7-20101029.jar. you are right! Thank you very much, at least this can be closed. |