Hi, I have a parsing error when trying to read an excel file

Environment : jdk 1.4.2 under Windows XP SP1, error identical under poi
2.0, 2.5.1 and 3.0-alpha2-20060616, parsing an a file created with excel
2002 containing some french characters :

HSSFWorkbook hssfWorkbook = new HSSFWorkbook(new POIFSFileSystem(new
BufferedInputStream(new FileInputStream("MyFile.xls"))));

Code worked a few days ago but failed since some changes in the excel file

java.lang.reflect.InvocationTargetException
      at sun.reflect.GeneratedConstructorAccessor9.newInstance(Unknown
Source)
      at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
      at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:213)
      at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:149)
      at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:183)
      at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:152)
      at
com.bnpparibas.grp.framework.testing.testpack.TestPackReader.<init>(TestPackReader.java:114)
      at
com.bnpparibas.grp.framework.testing.testpack.TestPackReaderTest.testTestPack(TestPackReaderTest.java:13)
      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:324)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at junit.textui.TestRunner.doRun(TestRunner.java:116)
      at
com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:69)
      at junit.textui.TestRunner.doRun(TestRunner.java:109)
      at
com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:24)
      at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118)
      at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
      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:324)
      at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of
range: 12007
      at java.lang.String.checkBounds(String.java:287)
      at java.lang.String.<init>(String.java:319)
      at
org.apache.poi.util.StringUtil.getFromCompressedUnicode(StringUtil.java:163)
      at
org.apache.poi.hssf.record.StringRecord.fillFields(StringRecord.java:89)
      at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
      at
org.apache.poi.hssf.record.StringRecord.<init>(StringRecord.java:51)
      ... 32 more

org.apache.poi.hssf.record.RecordFormatException: Unable to construct
record instance, the following exception occured: null
      at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:226)
      at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:149)
      at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:183)
      at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:152)
      at
com.bnpparibas.grp.framework.testing.testpack.TestPackReader.<init>(TestPackReader.java:114)
      at
com.bnpparibas.grp.framework.testing.testpack.TestPackReaderTest.testTestPack(TestPackReaderTest.java:13)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

Error is at
"return new String(string, offset, len, "ISO-8859-1");" in a
getFromCompressedUnicode method so I suspect an encoding issue but can't
spot it for the moment


Julien Kirch


This message and any attachments (the "message") is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 

                ---------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le 
"message") sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to