Edit an Excel spreadsheet with Java & JXL API
I'm currently developing a Java app that's supposed to fill a preformatted Excel file.
The file was originally coded using HTML tags, but I converted it to a real XLS file, removing the conditional formatting in the process (because I saw in JXL Yahoo! Group that it makes the thing crash). It then removed the NullPointerException
I had in the first place, but gave me another, a StringIndexOutOfBoundsException
this time.
I have to explain before showing you my code, that the Excel file I'm supposed to fill is contained in the JAR of my application. I extract it in a temporary file to be able to read it properly. This part of my code works perfectly since I use it in others apps without any issues.
Here's my code : http://pastebin.com/WcL9jZZD And here's the exception :
java.lang.StringIndexOutOfBoundsException: String index out of range: 1 at java.lang.String.charAt(String.java:686) at jxl.biff.EncodedURLHelper.getFile(EncodedURLHelper.java:60) at jxl.biff.EncodedURLHelper.getEncodedURL(EncodedURLHelper.java:51) at jxl.write.biff.SupbookRecord.initExternal(SupbookRecord.java:203) at jxl.write.biff.SupbookRecord.getData(SupbookRecord.java:254) at jxl.biff.WritableRecordData.getBytes(WritableRecordData.java:71) at jxl.write.biff.File.write(File.java:147) at jxl.write.biff.WritableWorkbookImpl.write(WritableWorkbookImpl.java:913) at qctomantis.tasks.ExcelWriter.doInBackground(ExcelWriter.java:128) at qctomantis.tasks.ExcelWriter.doInBackground(ExcelWriter.java:46) at org.jdesktop.swingworker.SwingWorker$1.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at org.jdesktop.swingworker.SwingWorker.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$W开发者_运维知识库orker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
Does anyone know how to solve this ? I found a topic in the JXL Yahoo! Group, but they do not give the answer... Thanks !
yes.You are probably using Excel 95 or earlier. Convert the file to Excel 97 or wait for their new release!
精彩评论