I tried to do this:

HSSFWorkbook wb = new HSSFWorkbook();
byte[] b = wb.getBytes();
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(b));
HSSFWorkbook h = (HSSFWorkbook)in.readObject();

but the line 3 throws the following exception:

Exception in thread main
java.io.StreamCorruptedException: invalid stream header
 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:737)
 at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253)
 at com.pakprint.paperbrowser.test.HSSFTest.main(HSSFTest.java:45)


What did I wrong?

----- Original Message ----- 
From: "Danny Mui" <[EMAIL PROTECTED]>
To: "POI Users List" <[EMAIL PROTECTED]>
Sent: Monday, December 06, 2004 7:33 PM
Subject: Re: Serialize/unserialize an HSSFWorkbook.


> Also check out the apache commons IO library.  Handy stuff there.
>
> Sullivan, Sean C - MWT wrote:
> > Try these classes:
> >
> > java.io.ByteArrayInputStream
> >
> > java.io.ByteArrayOutputStream
> >
> >
> >>-----Original Message-----
> >>From: Felipe Furtado Palma Dias [mailto:[EMAIL PROTECTED]
> >>Sent: Monday, December 06, 2004 3:22 PM
> >>To: POI Users List
> >>Subject: Re: Serialize/unserialize an HSSFWorkbook.
> >>
> >>Sorry, but what is the InputStream that I could use?
> >>
> >>Tks.
> >>
> >>----- Original Message -----
> >>From: "Danny Mui" <[EMAIL PROTECTED]>
> >>To: "POI Users List" <[EMAIL PROTECTED]>
> >>Sent: Monday, December 06, 2004 7:18 PM
> >>Subject: Re: Serialize/unserialize an HSSFWorkbook.
> >>
> >>
> >>
> >>>Building on what Siddharth recommended, serialize the file as a byte
> >>>array and transmit that.  There are input streams that are backed by
> >>>byte arrays.
> >>>
> >>>Felipe Furtado Palma Dias wrote:
> >>>
> >>>>My application is a JMS implementation, and I need to send a XLS
> >>
> >>message
> >>
> >>>>through the Internet. Do you know a mode to do this?
> >>>>
> >>>>
> >>>>----- Original Message -----
> >>>>From: "Sharma, Siddharth" <[EMAIL PROTECTED]>
> >>>>To: "POI Users List" <[EMAIL PROTECTED]>
> >>>>Sent: Monday, December 06, 2004 5:22 PM
> >>>>Subject: RE: Serialize/unserialize an HSSFWorkbook.
> >>>>
> >>>>
> >>>>I don't think you can serialize/deserialize an HSSFWorkbook in the
> >>
> >>true
> >>
> >>>>sense of object serialization, since it does not implement the marker
> >>>>interface Serializable or Externalizable.
> >>>>But depending on what you are trying to do, you may have workarounds.
> >>>>
> >>>>For example, you could write the HSSFWorkbook to an OutputStream
> >>>>(file/object) to persist it
> >>>>HSSFWorkbook.write(outputStreamInstance)
> >>>>
> >>>>And then read it in using an InputStream
> >>>>new HSSFWorkbook(inputStreamInstance)
> >>>>
> >>>>As I said earlier, this is not true object serialization, but then
> >>
> >>again
> >>I
> >>
> >>>>do not know what you are trying to do.
> >>>>
> >>>>
> >>>>-----Original Message-----
> >>>>From: Felipe Palma Dias [mailto:[EMAIL PROTECTED]
> >>>>Sent: Monday, December 06, 2004 2:06 PM
> >>>>To: [EMAIL PROTECTED]
> >>>>Subject: Serialize/unserialize an HSSFWorkbook.
> >>>>
> >>>>A need serialize/unserialize an HSSFWorkbook object.
> >>>>How can I do this?
> >>>>
> >>>>Tks.
> >>>>
> >>>>=====
> >>>>-------------------------------------------------------
> >>>>Felipe F. Palma Dias
> >>>>http://geocities.yahoo.com.br/palmadias/
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>_______________________________________________________
> >>>>Yahoo! Mail - Agora com 250MB de espa�o gratuito. Abra
> >>>>uma conta agora! http://br.info.mail.yahoo.com/
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>>
> >>>>
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to