DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <https://issues.apache.org/bugzilla/show_bug.cgi?id=44491>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44491 Summary: Old-style setting of POIFS properties doesn't work with POI 3.0.2 in all cases Product: POI Version: unspecified Platform: Other OS/Version: other Status: NEW Severity: normal Priority: P2 Component: POI Overall AssignedTo: [email protected] ReportedBy: [EMAIL PROTECTED] POI 3.0.2 includes handy accessors to DocumentSummary and Summary information streams. Unfortunately old-style setting of POIFS properties doesn't work any more in all cases. By "old-style" I mean direct constructing of DocumentSummaryInformation and SummaryInformation from POIFSFileSystem. "old-style" usage is important, this is how I discovered this bug just before copying POI 3.0.2 to production. Consider two code snippets: (1) set POIFS properties before constructing HSSFWorkbook (works fine) POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("test.xls")); //set POIFS properties after constructing HSSFWorkbook //(a piece of code that used to work up to POI 3.0.2) SummaryInformation summary1 = (SummaryInformation)PropertySetFactory.create(fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME)); summary1.setTitle(title); //write the modified property back to POIFS fs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME).delete(); fs.createDocument(summary1.toInputStream(), SummaryInformation.DEFAULT_STREAM_NAME); HSSFWorkbook wb = new HSSFWorkbook(fs); OutputStream out = new FileOutputStream(""test-saved.xls""); wb.write(out); out.close(); (2) set POIFS properties after constructing HSSFWorkbook (used to work up to POI 3.0.2, fails now) POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("test.xls")); HSSFWorkbook wb = new HSSFWorkbook(fs); //set POIFS properties after constructing HSSFWorkbook //(a piece of code that used to work up to POI 3.0.2) SummaryInformation summary1 = (SummaryInformation)PropertySetFactory.create(fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME)); summary1.setTitle(title); //write the modified property back to POIFS fs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME).delete(); fs.createDocument(summary1.toInputStream(), SummaryInformation.DEFAULT_STREAM_NAME); OutputStream out = new FileOutputStream(""test-saved.xls""); wb.write(out); out.close(); Unfortunately (2) doesn't work any more with POI 3.0.2. See the unit test in the patch. I think I found a workaround but I don't want to commit it without discussing. The idea is simple: don't read DocumentSummary and Summary in constructor. Instead, read them on first call of POIDocument.getSummaryInformation() or POIDocument.getDocumentSummaryInformation(). Nick, would you please confirm this change is OK to you? Regards, Yegor -- Configure bugmail: https://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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
