You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Jonathan Hodges <ho...@gmail.com> on 2015/11/05 13:14:52 UTC
InvalidFormatException with OPCPackage or XSSFWorkbook
Hi,
When I attempt to open an Excel file (.xlsx) file I receive the following
stack trace.
org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part
/_rels/.rels does not have any content type ! Rule: Package require content
types when retrieving a part from a package. [M.1.14]
at
org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:247)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:684)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:275)
The following is my code.
String xlsxPath = "/Users/jonathan.hodges/Downloads/daily-player-feed.xlsx";
FileInputStream is = new FileInputStream(xlsxPath)
OPCPackage pkg = OPCPackage.open(is);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
This file opens fine with Excel. I tried both as File and FileInputStream
and receive the same error. I tried HSSF as well which returns that the
file appears to be Office 2007+ XML.
Searching the web I found a similar unresolved bug from 2013.
https://mail-archives.apache.org/mod_mbox/poi-dev/201304.mbox/%3Cbug-54803-47293@https.issues.apache.org/bugzilla/%3E
Any ideas on how to resolve this?
Thanks!
Jonathan
Re: InvalidFormatException with OPCPackage or XSSFWorkbook
Posted by Jonathan Hodges <ho...@gmail.com>.
Hi Nick,
I was thinking more about this. Since this isn't a POI issue at all, maybe
instead of relaxing the compliance check I instead update the .xlsx file
programmatically with the correct OOXML. Any suggestions on tool(s) I
could use to view this and edit, taking into account the proper structure
and schemas? I realize I am probably heading off topic so feel free to
respond to be off list (hodgesz@gmail.com) if you want.
Thanks,
Jonathan
On Thu, Nov 5, 2015 at 5:58 AM, Jonathan Hodges <ho...@gmail.com> wrote:
> Thanks Nick. Will do.
>
>
> On Thu, Nov 5, 2015 at 5:57 AM, Nick Burch <ap...@gagravarr.org> wrote:
>
>> On Thu, 5 Nov 2015, Jonathan Hodges wrote:
>>
>>> Yes this file is from online and likely generated in a non-Excel system.
>>> When I re-saved the file it works.
>>>
>>> All this makes sense why it isn't working, but is there any other work
>>> around besides re-saving via Excel, preferably a programmatic option?
>>>
>>
>> Open a bug in bugzilla, attach a small file that shows the problem, and a
>> short unit test that triggers it. We can then take a look to see if we can
>> safely relax the compliance check that this file is failing on
>>
>>
>> Nick
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
>
Re: InvalidFormatException with OPCPackage or XSSFWorkbook
Posted by Jonathan Hodges <ho...@gmail.com>.
Thanks Nick. Will do.
On Thu, Nov 5, 2015 at 5:57 AM, Nick Burch <ap...@gagravarr.org> wrote:
> On Thu, 5 Nov 2015, Jonathan Hodges wrote:
>
>> Yes this file is from online and likely generated in a non-Excel system.
>> When I re-saved the file it works.
>>
>> All this makes sense why it isn't working, but is there any other work
>> around besides re-saving via Excel, preferably a programmatic option?
>>
>
> Open a bug in bugzilla, attach a small file that shows the problem, and a
> short unit test that triggers it. We can then take a look to see if we can
> safely relax the compliance check that this file is failing on
>
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: InvalidFormatException with OPCPackage or XSSFWorkbook
Posted by Nick Burch <ap...@gagravarr.org>.
On Thu, 5 Nov 2015, Jonathan Hodges wrote:
> Yes this file is from online and likely generated in a non-Excel system.
> When I re-saved the file it works.
>
> All this makes sense why it isn't working, but is there any other work
> around besides re-saving via Excel, preferably a programmatic option?
Open a bug in bugzilla, attach a small file that shows the problem, and a
short unit test that triggers it. We can then take a look to see if we can
safely relax the compliance check that this file is failing on
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: InvalidFormatException with OPCPackage or XSSFWorkbook
Posted by Jonathan Hodges <ho...@gmail.com>.
Yes this file is from online and likely generated in a non-Excel system.
When I re-saved the file it works.
All this makes sense why it isn't working, but is there any other work
around besides re-saving via Excel, preferably a programmatic option?
On Thu, Nov 5, 2015 at 5:23 AM, Nick Burch <ap...@gagravarr.org> wrote:
> On Thu, 5 Nov 2015, Jonathan Hodges wrote:
>
>> When I attempt to open an Excel file (.xlsx) file I receive the following
>> stack trace.
>>
>> org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part
>> /_rels/.rels does not have any content type ! Rule: Package require
>> content
>> types when retrieving a part from a package. [M.1.14]
>> at
>> org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:247)
>> at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:684)
>> at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:275)
>>
>
> Looks like a broken / invalid file to me. Do you know where it comes from?
> Perhaps generated by a non-Excel system?
>
> If you open the file in Excel, do a save-as, does the resaved file work
> properly?
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: InvalidFormatException with OPCPackage or XSSFWorkbook
Posted by Nick Burch <ap...@gagravarr.org>.
On Thu, 5 Nov 2015, Jonathan Hodges wrote:
> When I attempt to open an Excel file (.xlsx) file I receive the
> following stack trace.
>
> org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part
> /_rels/.rels does not have any content type ! Rule: Package require content
> types when retrieving a part from a package. [M.1.14]
> at
> org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:247)
> at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:684)
> at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:275)
Looks like a broken / invalid file to me. Do you know where it comes from?
Perhaps generated by a non-Excel system?
If you open the file in Excel, do a save-as, does the resaved file work
properly?
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org