java - Method Workbook.createWorkbook method in JexcelAPI throwing indexoutofbounds exception -
i using jexcelapi in java in order manipulate excel files. need make 2 copies of workbook object, 1 writableworkbook further manipulation, , 1 copy original workbook , save it, in case happens original object , it's writable copy, have backup. has been working long time until started getting arrayindexoutofbounds exception. stack trace looks this:
exception in thread "main" java.lang.indexoutofboundsexception: index: 62, size: 54 @ java.util.arraylist.rangecheck(arraylist.java:604) @ java.util.arraylist.get(arraylist.java:382) @ jxl.biff.formattingrecords.getxfrecord(formattingrecords.java:338) @ jxl.read.biff.cellvalue.getcellformat(cellvalue.java:144) @ jxl.write.biff.cellvalue.(cellvalue.java:129) @ jxl.write.biff.labelrecord.(labelrecord.java:116) @ jxl.write.label.(label.java:79) @ jxl.write.biff.sheetcopier.shallowcopycell(sheetcopier.java:808) @ jxl.write.biff.sheetcopier.shallowcopycells(sheetcopier.java:934) @ jxl.write.biff.sheetcopier.copysheet(sheetcopier.java:219) @ jxl.write.biff.writablesheetimpl.copy(writablesheetimpl.java:1584) @ jxl.write.biff.writableworkbookimpl.copyworkbook(writableworkbookimpl.java:971) @ jxl.write.biff.writableworkbookimpl.(writableworkbookimpl.java:343) @ jxl.workbook.createworkbook(workbook.java:339) @ jxl.workbook.createworkbook(workbook.java:320) @ musicpred.musicpreddebugtest.main(musicpreddebugtest.java:17) java result: 1
i have boiled down problem following snippet of code:
package musicpred; import java.io.file; import jxl.workbook; import jxl.write.writableworkbook; import java.io.*; import jxl.read.biff.biffexception; import jxl.write.*; public class musicpreddebugtest{ public static void main(string[] args) throws ioexception, biffexception, writeexception{ workbook workbook = workbook.getworkbook(new file ("nbscombined.xls")); writableworkbook backup = workbook.createworkbook(new file("backup.xls"),workbook); backup.write(); backup.close(); writableworkbook writableworkbook = workbook.createworkbook(new file("nbscombinedw.xls"), workbook); } } i noticed can create both writableworkbooks @ same time, , can write() second 1 (called "writableworkbook"), reason when try write() second 1 ("backup"), throws error. should note don't see particular significance outofbound indeces: not have dimension 54 in workbook (rows, columns, or sheets), nor trying replace array of length 62.
does have idea why may have started happening? have feeling has embarrassingly easy answer can't figure out, appreciated!
ok, have found out issue causing problem. in jexcelapi, if try copy workbook more once using overloaded createworkbook method, there bug happens if have ever tried change format of cell in original workbook in past. actually, not have have changed format-- if select 1 cell , go format cells window, click "general" format (which default), , hit ok , save workbook again, error thrown. if open window , select ok without clicking on "general", error not thrown. evidently, having clicked 1 of options in window , pressed "ok", if same format before, triggers error.
the worst part bug is permanent... thinking changing format (opening "format cells" window , clicking around) of cell corrupt workbook forever. if else can corroborate know i'm not crazy, appreciate it. though case, because see "formattingrecords" error @ top of stack trace. somehow excel stores information whether cell has had format changed in past. comes surprise me @ least.
best, paul
Comments
Post a Comment