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 2003/04/29 15:50:20 UTC

DO NOT REPLY [Bug 19427] New: - Internal files having names length of 12 cause Excel files to corrupt

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19427

Internal files having names length of 12 cause Excel files to corrupt

           Summary: Internal files having names length of 12 cause Excel
                    files to corrupt
           Product: POI
           Version: 2.0-dev
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: HPFS
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: eric_marcoux-qc@dmr.ca


Hi,

When a form, module, class or sheet in a VBA Project of a Excel file has a 
name length of 12, the file corrupts when saved with the POIFS API. Here is 
the sample code :

FileInputStream fis = new FileInputStream("classeur1.xls");
FileOutputStream fos = new FileOutputStream("classeur2.xls");
POIFSFileSystem p = new POIFSFileSystem(fis);
p.writeFilesystem(fos);
fos.close();

The problem occurs when a form, module, class or sheet has a name with the 
same length of the "_VBA_PROJECT" internal file (12 characters wide). When 
this occurs, the API place the "_VBA_PROJECT" internal file before the file 
having the same name length in the hierarchy and this seems to cause the 
problem. If I modify the method "compare(Object o1, Object o2)" of the inner 
class "PropertyComparator" of the public class "DirectoryProperty" to return a 
positive (or negative - depending on which parameter "_VBA_PROJECT" is 
passed : o1 or o2) value, the API places the "_VBA_PROJECT" internal file 
after the file resulting in an Excel file readable by MS Excel.

My fix works but I don't think it is a good one (because I am using the 
constant "_VBA_PROJECT" with the "equals" method). Before I submit it, I would 
like to know if there is a better approach because maybe I don't understand 
how the POIFS API is working.

I will attach the following files :
 the "DirectoryProperty.java" fixed class file ;
 the original Excel file (classeur1.xls) containing objects with name length 
of 12 ;
 a corrupt Excel file saved with the original POIFS API (classeur_bad.xls) ;
 a correct Excel file saved with the fix I suggest (classeur2.xls) ;
 and the test class file I use (TestBUG.java) to reproduce the problem.

I use the POI version "1.10.0-dev" (I have tested the case with the 1.8.0 and 
1.5.1 final versions ; they have the same problem too), JDK 1.4.1 on Eclipse 
IDE and Windows Excel XP on a Windows XP machine.

Thanks for your time.

Regards,
Eric Marcoux...