Summary: | Problem reading xls files created by Perl module Spreadsheet::WriteExcel (missing row records) | ||
---|---|---|---|
Product: | POI | Reporter: | Hubert Lin <hubertwslin> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | major | ||
Priority: | P2 | ||
Version: | 3.0-dev | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Linux | ||
Attachments: |
xls created with Perl module Spreadsheet::WriteExcel
perl src to write xls file simple java code to test poi |
Description
Hubert Lin
2006-12-15 22:10:13 UTC
Created attachment 19267 [details]
xls created with Perl module Spreadsheet::WriteExcel
This file can be opened without any problem in
1. MS office
2. OpenOffice
3. Google Docs & Spreadsheet
Created attachment 19268 [details]
perl src to write xls file
This code is availabe in the manpage of Spreadsheet::WriteExcel.
Is it an Excel 97+ format? We do not read anything but 97 or later. Those may. Was there a stack trace or any other info? Quoted from Spreadsheet::WriteExcel manpage: The Spreadsheet::WriteExcel module can be used to create a cross-platform Excel binary file. Multiple worksheets can be added to a workbook and formatting can be applied to cells. Text, numbers, formulas, hyperlinks and images can be written to the cells. The Excel file produced by this module is compatible with 97, 2000, 2002 and 2003. Here's the java code i used to parse the excel file: http://www.javaworld.com/javaworld/javaqa/2002-05/01-qa-0503-excel3.html The java code produce no error or exception, and nothing on the stdout. I'm a bit incredulous because POI (OLE2FS at the time) .01 was loosely based on the documentation produced by the author of that module. Secondly POI generally barfs with big fat stack traces when it doesn't like something. I'd suggest writing the mail list providing executable copies of each part and see if someone will run it for you and maybe figure out what's missing... Created attachment 19270 [details]
simple java code to test poi
Further test shows the flow never goes into the while( rows.hasNext() ) loop.
It's pretty easy to reproduce this, please give it a try. Thanks.
[h@mag ~]$ /usr/java/j2sdk1.4.2_13/bin/javac -classpath
poi-3.0-alpha3-20061216.jar POITest.java
[h@mag ~]$ /usr/java/j2sdk1.4.2_13/bin/java -classpath
poi-3.0-alpha3-20061216.jar:. POITest perl.xls
[h@mag ~]$ /usr/java/j2sdk1.4.2_13/bin/javac -classpath
poi-2.5.1-final-20040804.jar POITest.java
[h@mag ~]$ /usr/java/j2sdk1.4.2_13/bin/java -classpath
poi-2.5.1-final-20040804.jar:. POITest perl.xls
[h@mag ~]$
I too have just encountered this error (using poi-3.0.2beta2. It appears the perl module does not create any RowRecord records. so org.apache.poi.hssf.model.Sheet.createSheet(List, int, int) never populates the rows field. I have found a workaround to be to open the perl generated file in OpenOffice / Excel and then do a "save as" this will create the missing RowRecords. I hope this helps, Danny I have added a bug report to the Perl SpreadSheet :: WriteExcel module on cpan: the problem is known and will be corrected in a future release of WriteExcel. http://rt.cpan.org/Public/Bug/Display.html?id=32544 Even though the problem will be resolved on the Perl side, I think it is still a good idea to handle this issue on the Java side as well. -Danny fixed in svn r655278. HSSFSheet needed to be modified to handle files missing the ROW records. An extra fix was to set the default row height flag properly. The attached file (id=19267) was not so obscure. Quite a few existing HSSF junit example files already had this characteristic. POI was just ignoring all rows in those spreadsheets. |