https://issues.apache.org/bugzilla/show_bug.cgi?id=40039
David Fisher <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |RESOLVED Resolution| |WONTFIX --- Comment #5 from David Fisher <[email protected]> 2009-02-18 10:48:53 PST --- Jason had this analyzed correctly. GetBytes is the Workbook part of the output file. All binary results must always be wrapped in a POIFS to be a valid file. The BIFF8 can look like other older Excel files enough that it can sometimes read most of the file. Look at HSSFWorkbook and you can see how GetBytes is used: /** * Method write - write out this workbook to an Outputstream. Constructs * a new POI POIFSFileSystem, passes in the workbook binary representation and * writes it out. * * @param stream - the java OutputStream you wish to write the XLS to * * @exception IOException if anything can't be written. * @see org.apache.poi.poifs.filesystem.POIFSFileSystem */ public void write(OutputStream stream) throws IOException { byte[] bytes = getBytes(); POIFSFileSystem fs = new POIFSFileSystem(); // For tracking what we've written out, used if we're // going to be preserving nodes List excepts = new ArrayList(1); // Write out the Workbook stream fs.createDocument(new ByteArrayInputStream(bytes), "Workbook"); // Write out our HPFS properties, if we have them writeProperties(fs, excepts); if (preserveNodes) { // Don't write out the old Workbook, we'll be doing our new one excepts.add("Workbook"); // If the file had WORKBOOK instead of Workbook, we'll write it // out correctly shortly, so don't include the old one excepts.add("WORKBOOK"); // Copy over all the other nodes to our new poifs copyNodes(this.filesystem,fs,excepts); } fs.writeFilesystem(stream); //poifs.writeFilesystem(stream); } -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
