Return-Path: Delivered-To: apmail-poi-user-archive@www.apache.org Received: (qmail 4986 invoked from network); 24 Jul 2009 20:37:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 24 Jul 2009 20:37:31 -0000 Received: (qmail 43542 invoked by uid 500); 24 Jul 2009 20:38:35 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 43520 invoked by uid 500); 24 Jul 2009 20:38:35 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Received: (qmail 43510 invoked by uid 99); 24 Jul 2009 20:38:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Jul 2009 20:38:35 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [72.167.82.86] (HELO p3plsmtpa01-06.prod.phx3.secureserver.net) (72.167.82.86) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 24 Jul 2009 20:38:25 +0000 Received: (qmail 30936 invoked from network); 24 Jul 2009 20:38:02 -0000 Received: from unknown (24.247.222.48) by p3plsmtpa01-06.prod.phx3.secureserver.net (72.167.82.86) with ESMTP; 24 Jul 2009 20:38:02 -0000 Message-ID: <4A6A1BA4.1010504@mishlerlabs.com> Date: Fri, 24 Jul 2009 16:37:56 -0400 From: Abe Mishler Organization: Mishler Labs, LLC User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: user@poi.apache.org Subject: Malformed xls with struts2 and POI 3.5-beta6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi all, I need some pointers/help with creating an .xls file for download from a servlet container. Specifically, I have a struts2 project running inside Tomcat 5.5. And I'm using POI 3.5-beta6. I am able to use POI to create a workbook and fill it with data. The problem is after I download the file, the binary header doesn't match the expected: D0 CF 11 E0 A1 B1 1A E1 signature. Instead, I get: 09 08 10 00 00 06 05 00 D3 10 CC 07 41 ... I'm definitely getting a binary file. When I open the file using MS Excel 2003 SP2, it goes into file recovery mode telling me the file is damaged beyond repair, etc. After I click "Don't Send" a couple times on the error dialogs, my data is there, although without the formatting (Date values look like numbers). I have one immediate concern: All of the examples use wb.write(fileOut), however, AFAIK, that's not the way for writing data out of a servlet container for download. I'm familiar with creating an InputStream for a file download. I've included a basic execute() method from my action which demonstrates how I export the data to the user for download. Is this causing the malformed file? How do I get the workbook bytes[] into an InputStream properly? Thanks in advance, Abe == I have an action class with an execute() method as follows: public String execute() throws Exception { Workbook workbook = new HSSFWorkbook(); Sheet s = workbook.createSheet("sheet"); Row r = s.createRow(0); Cell c = r.createCell(0); c.setCellValue("hello world"); ByteArrayInputStream bais = new ByteArrayInputStream( ((HSSFWorkbook) workbook).getBytes()); inputStream = bais; return SUCCESS; } and the necessary getter for inputStream. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org