You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2006/12/19 05:08:32 UTC

DO NOT REPLY [Bug 40039] - Excel file repaired after being created

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40039>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40039





------- Additional Comments From epilz@altastrada.com  2006-12-18 20:08 -------
I just ran into this myself. The issue stems from using HFFSWorkbook#getBytes()
to create an input stream that eventually gets saved as a file. From the docs
for getBytes() I think it may just be a misunderstanding of what the method
returns. 

Here's what I was doing that caused the problem:

HFFSWorkbook wb = new HFFSWorkbook();
// add sheets, rows, and cells.
return new ByteArrayInputStream(wb.getBytes());

The way I ended up solving this is as follows:

    HFFSWorkbook wb = new HFFSWorkbook();
    // add sheets, rows, and cells.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        workbook.write(baos);
        return new ByteArrayInputStream(baos.toByteArray());
    } catch (IOException e) {
        try { baos.close(); } catch (IOException ee) { }
    }

- Erik


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/