I am using JexcelAPI in java in order to manipulate excel files. I need to make 2 copies of a Workbook object, one a WritableWorkbook for further manipulation, and one simply to copy from the original Workbook and then save it, so that in case anything happens to the original object and it's writable copy, I will have a backup. This has been working for a long time until recently I started getting an ArrayIndexOutOfBOunds exception. The stack trace looks like this:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 62, Size: 54 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at jxl.biff.FormattingRecords.getXFRecord(FormattingRecords.java:338) at jxl.read.biff.CellValue.getCellFormat(CellValue.java:144) at jxl.write.biff.CellValue.(CellValue.java:129) at jxl.write.biff.LabelRecord.(LabelRecord.java:116) at jxl.write.Label.(Label.java:79) at jxl.write.biff.SheetCopier.shallowCopyCell(SheetCopier.java:808) at jxl.write.biff.SheetCopier.shallowCopyCells(SheetCopier.java:934) at jxl.write.biff.SheetCopier.copySheet(SheetCopier.java:219) at jxl.write.biff.WritableSheetImpl.copy(WritableSheetImpl.java:1584) at jxl.write.biff.WritableWorkbookImpl.copyWorkbook(WritableWorkbookImpl.java:971) at jxl.write.biff.WritableWorkbookImpl.(WritableWorkbookImpl.java:343) at jxl.Workbook.createWorkbook(Workbook.java:339) at jxl.Workbook.createWorkbook(Workbook.java:320) at musicpred.musicpreddebugtest.main(musicpreddebugtest.java:17) Java Result: 1
I have boiled down the problem to the 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 that I can create both WritableWorkbooks at the same time, and I can even write() the second one (called "writableWorkbook"), but for some reason when I try to write() the second one ("backup"), it throws the error. I should also note that I don't see any particular significance to the outofbound indeces: I am do not have anything with dimension 54 in my workbook (rows, columns, or sheets), nor am I trying to replace anything with an array of length 62.
Does any have any idea why this may have suddenly started happening? I have a feeling it has an embarrassingly easy answer but I can't figure it out, so any help would be greatly appreciated!