WritableFont doesn’t like to be static!


While using the tool JExcelAPI within my Java application to generate Excel spreadsheets, I got the following exception:

java.lang.ArrayIndexOutOfBoundsException: 5
	at jxl.biff.IndexMapping.getNewIndex(IndexMapping.java:68)
	at jxl.biff.FormattingRecords.rationalize(FormattingRecords.java:388)
	at jxl.write.biff.WritableWorkbookImpl.rationalize(WritableWorkbookImpl.java:988)
	at jxl.write.biff.WritableWorkbookImpl.write(WritableWorkbookImpl.java:692)
	...


It appears that this exception occurs only when you try to generate more than one Excel spreadsheet! How strange is that! 8-O
After a bit of investigation, it seems that the problem comes from the use of the static modifier with a jxl.write.WritableFont variable.

I unfortunately don’t have the time to check the JExcelAPI code source to understand the root cause.
So my advice would be: “if you get EXACTLY the same stack trace, simply delete any static modifier you used with the WritableFont variables”. :-)

, , , , ,


  1. #1 by GM Raj on 25 Jan 2011 - 14:35

    Hi,

    Thanks for this posting. Exactly after an year of this posting, I got benefited. This really helped me to overcome my one full day headache.

    Thanks again.

  2. #2 by remi on 01 Jul 2011 - 15:57

    THX a lot ! It works perfectly, just by removing static word (final is still OK).

(will not be published)