ok, that a bit tricky thing ! but once your excel is created, you can still open it by using Runtime.getRunTime().exec() method.... however, you will have to store the file first on the users local machine (which you said is not elegant because of cleanup issues).
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html I am assuming that in the exec method if you just pass "excel <file path>", it should equally apply to all versions of Ms-Excel... but that's just a guess work, you might want to test it first.. "Andrew Shumway" <[EMAIL PROTECTED]> 05/15/2006 05:36 PM Please respond to "POI Users List" <[email protected]> To "'POI Users List'" <[email protected]> cc Subject RE: Launch Excel and load memory resident HSSFWorkbook Steaming the HSSFWorkbook out to the web client after changing the mime type works for servlet type applications. It's the Swing client that I'm having difficulty with. Sorry for not mentioning that in the original post. --andrew shumway -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, May 15, 2006 3:26 PM To: POI Users List Subject: Re: Launch Excel and load memory resident HSSFWorkbook 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/HSSFWork book.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+".x ls"); 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. +=========================================================+ --------------------------------------------------------------------- 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. +=========================================================+
