Bug 41187

Summary: Problem reading xls files created by Perl module Spreadsheet::WriteExcel (missing row records)
Product: POI Reporter: Hubert Lin <hubertwslin>
Component: HSSFAssignee: 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
Hello,

I had problem reading xls files created with Perl module Spreadsheet::WriteExcel
(v2.17, released May 21, 2006)

Sample files to follow.
Comment 1 Hubert Lin 2006-12-15 22:12:24 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
Comment 2 Hubert Lin 2006-12-15 22:14:02 UTC
Created attachment 19268 [details]
perl src to write xls file

This code is availabe in the manpage of Spreadsheet::WriteExcel.
Comment 3 Andy Oliver 2006-12-15 22:48:48 UTC
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?
Comment 4 Hubert Lin 2006-12-15 23:18:33 UTC
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
Comment 5 Hubert Lin 2006-12-15 23:19:51 UTC
The java code produce no error or exception, and nothing on the stdout.
Comment 6 Andy Oliver 2006-12-16 05:13:02 UTC
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...
Comment 7 Hubert Lin 2006-12-17 06:13:05 UTC
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 ~]$
Comment 8 dkatzel 2008-01-22 13:25:44 UTC
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
Comment 9 dkatzel 2008-01-22 15:27:57 UTC
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
Comment 10 Josh Micich 2008-05-11 01:25:05 UTC
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.