You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Rohit Sharma <rs...@modeln.com> on 2011/06/22 10:49:32 UTC

Error while opening xlsx file

Hi,

I am trying to read an XLSX file using the eventuser model of POI. But I'm
stuck at this point.

The OPCPackage's open method uses an InputStream as the parameter, to
construct this InputStream from an InputSource ( having a character stream)
I use the ReaderInputStream class. After this conversion, when the
processAllSheets method is called, the OPCPackage throws an exception while
opening this InputStream ( happens for all xlsx files)


org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should
contain a content type part [M1.13]
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:147)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:592)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:222)


--
Thanks

Re: Error while opening xlsx file

Posted by Rohit Sharma <rs...@modeln.com>.
Hi,

On Thu, Jun 23, 2011 at 3:11 AM, Nick Burch <ni...@alfresco.com> wrote:

> On Wed, 22 Jun 2011, Rohit Sharma wrote:
>
>> The OPCPackage's open method uses an InputStream as the parameter, to
>> construct this InputStream from an InputSource ( having a character stream)
>> I use the ReaderInputStream class. After this conversion, when the
>> processAllSheets method is called, the OPCPackage throws an exception while
>> opening this InputStream ( happens for all xlsx files)
>>
>
> I'm not quite following you here, but I'm slightly worried you have the
> wrong idea
>
> You should either pass the File to OPCPackage, or an InputStream that'll
> read the contents of the file. The exception you're getting indicates you're
> not passing a valid .xlsx file to OPCPackage, possibly because you're doing
> something odd with the inputstream
>
> I am converting an InputSource to an InputStream and passing it on to the
OPCPackage, and am getting this exception. I'll look into some more details
to find if there's something wrong with the conversion, because if I
directly use the InputStream ( without conversion to InputSource ) it works
like a charm.

Anyway this conversion from InputStream to an InputSource only creates more
problems.

--
Thanks



> Nick
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.**org<us...@poi.apache.org>
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Error while opening xlsx file

Posted by Nick Burch <ni...@alfresco.com>.
On Wed, 22 Jun 2011, Rohit Sharma wrote:
> The OPCPackage's open method uses an InputStream as the parameter, to 
> construct this InputStream from an InputSource ( having a character 
> stream) I use the ReaderInputStream class. After this conversion, when 
> the processAllSheets method is called, the OPCPackage throws an 
> exception while opening this InputStream ( happens for all xlsx files)

I'm not quite following you here, but I'm slightly worried you have the 
wrong idea

You should either pass the File to OPCPackage, or an InputStream that'll 
read the contents of the file. The exception you're getting indicates 
you're not passing a valid .xlsx file to OPCPackage, possibly because 
you're doing something odd with the inputstream

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org