|Summary:||Incorrect HSSFWorkbook.getNumberOfSheets() and corrupt Excel file|
|Component:||HSSF||Assignee:||POI Developers List <dev>|
Description Matthew 2009-04-01 22:46:04 UTC
Created attachment 23435 [details] problem.xls I use following codes to read attached "problem.xls" Excel file, the Excel file contains 5 worksheets but HSSFWorkbook.getNumberOfSheets() output 1 only. And write the workbook out, it cannot be opened by MS Excel. -- FileInputStream fis = new FileInputStream("problem.xls"); POIFSFileSystem poifs = new POIFSFileSystem(fis); HSSFWorkbook wb = new HSSFWorkbook(poifs); System.out.println("wb.getNumberOfSheets() = " + wb.getNumberOfSheets()); FileOutputStream os = new FileOutputStream("problem.output.xls"); wb.write(os);
Comment 2 Yegor Kozlov 2009-04-04 06:30:17 UTC
Looks like a regression introduced in r757520. If I comment out the line 229 then the number of sheets is 5 and the output is readable by Excel. The offending line: _psBlock.addLateHeaderFooter(rs.getNext()); Josh, please confirm the bug. Yegor
Comment 3 Matthew 2009-04-23 19:43:37 UTC
Since this bug is a blocker in our current project, is there any update on this bug? Thanks a lot.
Comment 4 Josh Micich 2009-05-10 14:50:53 UTC
Fixed in svn r773412 junit added It seems like this bug was evident in existing test samples, but the junits were not checking the number of sheets in those cases. This change is just another band-aid. The code is long overdue for refactoring the chart/user-view stuff into dedicated RecordAggregate sub-classes.