You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2008/03/05 19:58:45 UTC

DO NOT REPLY [Bug 44542] New: cannot open a excel file in Excel 2003 generated by poi

https://issues.apache.org/bugzilla/show_bug.cgi?id=44542

           Summary: cannot open a excel file in Excel 2003  generated by poi
           Product: POI
           Version: 3.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: rusoloco@gmail.com


Created an attachment (id=21629)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21629)
this file open ok in excel and openoffice

Hi:

I code to generate excel files  using PO API , I've got the file OK and the
most rare thing is that file is be able to open with openoffice  but with 
Excel microsoft version 2000, 2003 and 2007, it can't.

When i tried to open the file excel said that the file is so damaged that it
has to be repair, when you see the file repaired the only thing that is not as
original file is the second row, that have the titles of the next rows.

This problem only happen when the sheet have more > 100 rows  or when in one
cell, have a lot of characters 


I attached three examples files.

Is there something wrong in files that produce this error ?

Thanks


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542





--- Comment #8 from Yegor Kozlov <ye...@dinom.ru>  2008-03-06 07:15:39 PST ---
1. I can't reproduce it either. I created a test based on the attached code and
it produces correct XLS files.

What is strange to me is that the generated XLS is just data. There are no rich
text, formulas, graphics, any of advanced XLS/POI features, etc. 
I can't see why POI would produce wrong output. 

2. If I try to read any of the problem files in POI I get the same exception:

Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException:
Unable to construct record instance
        at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:204)
        at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:122)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:204)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:256)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:237)
        at org.apache.poi.hssf.scratchpad.Test44542.main(Test44542.java:47)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:192)
        ... 10 more
Caused by: java.lang.NegativeArraySizeException
        at
java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:44)
        at java.lang.StringBuffer.<init>(StringBuffer.java:92)
        at
org.apache.poi.hssf.record.UnicodeString.fillFields(UnicodeString.java:225)
        at
org.apache.poi.hssf.record.UnicodeString.<init>(UnicodeString.java:115)
        at
org.apache.poi.hssf.record.SSTDeserializer.manufactureStrings(SSTDeserializer.java:49)
        at org.apache.poi.hssf.record.SSTRecord.fillFields(SSTRecord.java:364)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
        at org.apache.poi.hssf.record.SSTRecord.<init>(SSTRecord.java:101)
        ... 15 more


So, if it is a POI bug it might be related to SSTRecord. 

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.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542





--- Comment #5 from Josh Micich <jo...@gildedtree.com>  2008-03-05 15:09:05 PST ---
Sorry, the code you attached is not quite what I meant.  
It still has references to other things:

CampoDTO cannot be resolved to a type
DataDTO cannot be resolved to a type
FormatoDTO cannot be resolved to a type
MetadatosService cannot be resolved to a type
MetadatosUtil cannot be resolved
ResultadoDTO cannot be resolved to a type
TipoDatoConstants cannot be resolved

Better than sending all of that stuff, replace them with in the example with
whatever simple alternative that makes the code still produce the bad XLS
files.

Make a static void main(String[]) method, and make this class depend on nothing
but POI.

Sorry about the extra trouble, but this is probably a faster path to
identifying the bug (unless someone knows an easy way to diagnose exactly how
the attached XML files break the BIFF spec).


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542





--- Comment #7 from Josh Micich <jo...@gildedtree.com>  2008-03-05 21:00:23 PST ---
(In reply to comment #6)
> Created an attachment (id=21634)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21634) [details]
> simple test to write random data to excel file
> this is a fast code from original code, trying to reproduce the corrupt file 
> you have to put two parameters the number of sheets and number of rows, to
> reproduce the error you have to put a lot of rows 

One more thing - in addition to reproducing the error, the code has to also
compile and run.

The code you sent is a long way from running.  There are mismatched brackets
(which I can't fix easily because the indenting is all wrong).  Once I got it
executing, I got a ClassCastException from this expression: (Map<String,
Object>) formato.get("data");

There are all sorts of apparent errors where the code keeps updating a map with
the same key and value (map only gets one entry) or the same map instance is
added to a list many times.

After attempting to fix all of this I ran the code with (hojas=1000,
renglones=256) and  the spreadsheet still opened in Excel OK.  Perhaps my fixes
obliterated some important part of the code.


I'm sorry if this is tedious, but it really helps to have some example code
that allows other people to easily reproduce your error.  Can you please
re-attach the example class after making sure that it actually compiles, runs,
and reproduces the error.


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] cannot open a excel file in Excel 2003 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542





--- Comment #2 from ivan <ru...@gmail.com>  2008-03-05 11:02:19 ---
Created an attachment (id=21631)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21631)
this file in sheet 201 in cell B2 have a lot of words than excel can´t open


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542





--- Comment #9 from ivan <ru...@gmail.com>  2008-03-06 17:33:21 PST ---
Created an attachment (id=21645)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21645)
a working test to create multiple sheets 

Sorry  about last code, this code is fully operational, with this test the
memory is exausted, but i can't reproduce the wrong files i make atest wtih 250
rows and 100 sheets but these are only strings cells 

maybe the problem is when i'm setting multiple cells formats in each sheet 


greetings


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542





--- Comment #4 from ivan <ru...@gmail.com>  2008-03-05 12:51:26 ---
Created an attachment (id=21632)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21632)
this is a extract of the code that build the excel file, error are omitted

This is a part of the code, 
it takes data for maps and put this data in rows or colums depending in number
of the dataDTO

I ommited the part in which depending of the type of object it set the type of
cell, because is a large switch case 


hope this can help to figurate out the problem , and the funny thing that
openoffice can open this file.

greetings 


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] cannot open a excel file in Excel 2003 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542





--- Comment #1 from ivan <ru...@gmail.com>  2008-03-05 11:00:21 ---
Created an attachment (id=21630)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21630)
this file can´t open correctly in excel it was many rows in sheet 205 


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542


ivan <ru...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #21632|application/octet-stream    |text/plain
          mime type|                            |




-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|cannot open a excel file in |Cannot open a excel file in
                   |Excel 2003  generated by poi|Excel 2003/2007 generated by
                   |                            |poi




--- Comment #3 from Josh Micich <jo...@gildedtree.com>  2008-03-05 11:23:46 ---
I tried to open in Excel 2007, and both files give this message box:
"Excel found unreadable content in 'MuchtextInOneCell.xls'. Do you want to
recover the contents of this workbook? If you trust the source of this
workbook, click Yes."

I guess it's the same as the behaviour from 2003 (so I changed this bug's
summary).


It would help greatly in solving this bug if you could send a small example of
code that reproduces files with this characteristic.  If you are not sure how
to do this, start with the code you have, and keep cutting out bits and pieces
while making sure that the bugs still occur.  Hopefully you can get it down
below 100 lines of code or so.


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542





--- Comment #6 from ivan <ru...@gmail.com>  2008-03-05 18:55:21 PST ---
Created an attachment (id=21634)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21634)
simple test to write random data to excel file

this is a fast code from original code, trying to reproduce the corrupt file 
you have to put two parameters the number of sheets and number of rows, to
reproduce the error you have to put a lot of rows 


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44542] Cannot open a excel file in Excel 2003/ 2007 generated by poi

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44542


Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX




-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org