Andrew,
        Following code snippet might be helpful... what we are doing here 
is that we are streaming the BLOB object from the database and setting it 
in the http response. In your case, you can simply use the HSSFWorkBook's 
"write" method along with the POIFSFileSystem to do the streaming. 

http://jakarta.apache.org/poi/apidocs/org/apache/poi/hssf/usermodel/HSSFWorkbook.html#write(java.io.OutputStream)

remember that in each of these cases, the end user will see a window's 
dialogbox asking the user to either save / open / cancel / help options. 
If the user opts for "open" then Ms-Excel will be launched and your excel 
opened.

{
        String mimeType = "";
        mimeType = "Application/vnd.ms-excel";
 
response.setHeader("Content-Disposition","attachment;filename="+fileName+".xls");
 
        response.setContentType(mimeType);
        servOut = response.getOutputStream();

        InputStream in = dataBlob.getBinaryStream();
        long len = dataBlob.length();
        writeBuffer = dataBlob.getBytes(1,(int)len);
        int numRead = 0;
        int bufLength = in.read(readBuffer);

        while(bufLength != -1)
        {
                System.arraycopy(readBuffer, 0, writeBuffer, numRead, 
bufLength);
                servOut.write(writeBuffer, numRead, bufLength);
                numRead += bufLength ;
                bufLength = in.read(readBuffer);
        }
 
        in.close();
        servOut.flush();
        servOut.close();
}

I hope this is what you are looking for... 

Regards,
Sumit Machwe




"Andrew Shumway" <[EMAIL PROTECTED]> 
05/15/2006 04:25 PM
Please respond to
"POI Users List" <[email protected]>


To
"'POI Users List'" <[email protected]>
cc

Subject
Launch Excel and load memory resident HSSFWorkbook






Hello

I have an HSSFWorkbook object that is created within my application.  I 
now
want to launch Excel and display this Workbook so that the user can view,
update and possibly save.

I've been searching thru the FAQ and JavaDocs but I don't see a hook for
this. If I have to I can create a temp file but I'd rather not as it leads
to cleanup issues.  Even in this case though I'm not sure how to launch
excel on the client given that different versions install differently etc.

Any ideas?


--andrew shumway
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/





+=========================================================+
This message may contain confidential and/or privileged
information.  If you are not the addressee or authorized to
receive this for the addressee, you must not use, copy,
disclose or take any action based on this message or any
information herein.  If you have received this message in
error, please advise the sender immediately by reply e-mail
and delete this message.  Thank you for your cooperation.
+=========================================================+

Reply via email to