Bug 61041 - my code can't read the xlsx, casuse by: ZIP_Read: specified offset out of range
Summary: my code can't read the xlsx, casuse by: ZIP_Read: specified offset out of range
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.16-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-25 16:33 UTC by Ian Sue
Modified: 2017-04-26 15:54 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Sue 2017-04-25 16:33:40 UTC
org.apache.poi.openxml4j.exceptions.InvalidFormatException: Can't read content types part !
	at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:102)
	at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.<init>(ZipContentTypeManager.java:54)
	at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:253)
	at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:758)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:298)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:201)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:319)
	at XlxsReader.main(XlxsReader.java:14)
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: ZIP_Read: specified offset out of range
	at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:401)
	at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:100)
	... 7 more

I don't know why,the Excel downloaded from a website.It's so weird,when it's downloaded completely,I opened it with EXCEL and I deleted the last blank line (for example,the 28th line has data,but the 28th is the last .I deleted the 29th or more and I ran my code, it worked).
But i did nothing and opened it with Office,it was normal.I just wanna know how to solve it.Office 2007 and above
Comment 1 Javen O'Neal 2017-04-25 17:13:51 UTC
Can you post the Excel file and a code snippet that produced the problem?
Comment 2 Ian Sue 2017-04-26 08:34:10 UTC
(In reply to Javen O'Neal from comment #1)
> Can you post the Excel file and a code snippet that produced the problem?

Thank you,I find the reason.
Becase the POI unzips Excel files with java.util.zip.*,When POI begin to unzip the Excel file of mine,it fails.
I get another way to solve it.
Thank a lot.
Comment 3 Javen O'Neal 2017-04-26 15:54:09 UTC
Since we didn't change the code it Java docs, I'm changing the status to WONTFIX, since there's nothing we can do without an example Except file that breaks POI.

If anyone else has the same problem, please reopen this bug so we can fix this bug for everyone.