Return-Path: Delivered-To: apmail-jakarta-poi-user-archive@www.apache.org Received: (qmail 87769 invoked from network); 23 Feb 2007 23:40:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Feb 2007 23:40:48 -0000 Received: (qmail 78236 invoked by uid 500); 23 Feb 2007 23:40:55 -0000 Delivered-To: apmail-jakarta-poi-user-archive@jakarta.apache.org Received: (qmail 78217 invoked by uid 500); 23 Feb 2007 23:40:55 -0000 Mailing-List: contact poi-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "POI Users List" Reply-To: "POI Users List" Delivered-To: mailing list poi-user@jakarta.apache.org Received: (qmail 78205 invoked by uid 99); 23 Feb 2007 23:40:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Feb 2007 15:40:55 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [198.240.130.81] (HELO ny-bas08.csfb.com) (198.240.130.81) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Feb 2007 15:40:40 -0800 Received: from snyc11p30740.csfb.cs-group.com (snyc11p30740.csfb.mail [169.37.102.102]) by ny-bas08.csfb.com (Postfix) with ESMTP id 68C0433FC for ; Fri, 23 Feb 2007 18:40:16 -0500 (EST) Received: from 137.34.56.50 by snyc11p30740.csfb.cs-group.com with ESMTP (P30740N (Email Firewall v6.3.0)); Fri, 23 Feb 2007 18:40:13 -0500 X-Server-Uuid: 69F8E79C-F4C9-40AA-A508-D17673D08792 Received: by spri11p31500.corpny.csfb.com with Internet Mail Service ( 5.5.2655.55) id ; Fri, 23 Feb 2007 18:40:13 -0500 Message-ID: <89D59C407D04D54AA82DC8BA312D430D39D42B39@enyc11p32001.corpny.csfb.com> From: "Siwicki, Grace" To: "'POI Users List'" Subject: RE: Unable to display workbook in JSP Date: Fri, 23 Feb 2007 18:40:03 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2655.55) X-WSS-ID: 69C1A4D746G163372-01-03 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Well I got it to work. I had to remove the newline between the <%@ page import %> and <% HSSF code ... %>. So my code looks like this: <%@ page import="org.apache.poi.poifs.filesystem.*, org.apache.poi.hssf.usermodel.*, java.io.*, java.util.*" %><% try { //FileOutputStream out1 = new FileOutputStream("/tmp/gracework.xls"); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet(); HSSFRow r = null; HSSFCell c = null; // HSSFCellStyle cs = wb.createCellStyle(); // HSSFDataFormat df = wb.createDataFormat(); wb.setSheetName(0, "one"); for (int rownum=0; rownum<4; rownum++) { r = s.createRow(rownum); for (short cellnum=0; cellnum<5; cellnum++) { c = r.createCell(cellnum); c.setCellValue(cellnum); } } //response.setContentType("application/octet-stream"); response.setContentType("application/vnd.ms-excel"); //response.setContentType("application/binary"); response.setHeader("Content-Disposition", "attachment; filename=monk.xls"); ServletOutputStream o = response.getOutputStream(); wb.write(o); o.close(); //wb.write(out1); //o.flush(); //o.close(); //out.close(); } catch (Exception e) { e.printStackTrace(); } %> -----Original Message----- From: David Henry [mailto:dave.henry@fedex.com] Sent: Friday, February 23, 2007 6:30 PM To: POI Users List Subject: RE: Unable to display workbook in JSP I, too, had this problem and ended up just putting my HSSF code into a servlet and calling it in my JSP. Sorry, no help, but it worked fine this way. - David -----Original Message----- From: Siwicki, Grace [mailto:grace.siwicki@credit-suisse.com] Sent: Friday, February 23, 2007 5:29 PM To: poi-user@jakarta.apache.org Subject: Unable to display workbook in JSP Hi, I've created a workbook in my JSP and am trying to display the output back in my JSP. But I am getting junk data displayed in my browser. Can someone look at my code and tell me what I'm doing wrong? I've used the same code to write the output to the filesystem and that seems to work fine but I can't seem to write it back to the browser. Any help would be appreciated. Grace <%@ page import="org.apache.poi.poifs.filesystem.*, org.apache.poi.hssf.usermodel.*, java.io.*, java.util.*" %> <% try { //FileOutputStream out1 = new FileOutputStream("/tmp/gracework.xls"); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s = wb.createSheet(); HSSFRow r = null; HSSFCell c = null; // HSSFCellStyle cs = wb.createCellStyle(); // HSSFDataFormat df = wb.createDataFormat(); wb.setSheetName(0, "one"); for (int rownum=0; rownum<4; rownum++) { r = s.createRow(rownum); for (short cellnum=0; cellnum<5; cellnum++) { c = r.createCell(cellnum); c.setCellValue(cellnum); } } response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment; filename=blah.xls"); ServletOutputStream o = response.getOutputStream(); wb.write(o); o.close(); } catch (Exception e) { e.printStackTrace(); } %> ======================================================================== ====== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ======================================================================== ====== --------------------------------------------------------------------- To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/ ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== --------------------------------------------------------------------- To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/