This code rises exception (see attached file): new HSSFWorkbook(new FileInputStream("2.xls")).getSheetAt(0).getRow(0).getRowStyle(); Exception rises in cases when row has double line border: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 12345, Size: 71 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at org.apache.poi.hssf.model.WorkbookRecordList.get(WorkbookRecordList.java:50) at org.apache.poi.hssf.model.Workbook.getExFormatAt(Workbook.java:787) at org.apache.poi.hssf.usermodel.HSSFRow.getRowStyle(HSSFRow.java:575)
Created attachment 25385 [details] Example
Does the problem still occur with a recent nightly build / recent svn checkout?
I can verify that this bug still exists in 3.8. I got this error dump: java.lang.IndexOutOfBoundsException: Index: 8400, Size: 589 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at org.apache.poi.hssf.model.WorkbookRecordList.get(WorkbookRecordList.java:50) at org.apache.poi.hssf.model.InternalWorkbook.getExFormatAt(InternalWorkbook.java:832) at org.apache.poi.hssf.usermodel.HSSFRow.getRowStyle(HSSFRow.java:587) at org.apache.poi.hssf.usermodel.HSSFRow.getRowStyle(HSSFRow.java:39)
(In reply to comment #3) > I can verify that this bug still exists in 3.8. I got this error dump: > > java.lang.IndexOutOfBoundsException: Index: 8400, Size: 589 > at java.util.ArrayList.RangeCheck(ArrayList.java:547) > at java.util.ArrayList.get(ArrayList.java:322) > at > org.apache.poi.hssf.model.WorkbookRecordList.get(WorkbookRecordList.java:50) > at > org.apache.poi.hssf.model.InternalWorkbook.getExFormatAt(InternalWorkbook. > java:832) > at org.apache.poi.hssf.usermodel.HSSFRow.getRowStyle(HSSFRow.java:587) > at org.apache.poi.hssf.usermodel.HSSFRow.getRowStyle(HSSFRow.java:39) POI can read the attached file and we have a unit test for it. Can you upload a sample file that demonstrates the problem?
Created attachment 30993 [details] [PATCH] Bug 49237 - limit xfIndex read to 12 bits Currently the RowRecord class tries to read the full 16 bits for the xfIndex, but spec only specifies 12 bits. (see http://msdn.microsoft.com/en-us/library/dd906757(v=office.12).aspx). In the original test file the higher bits for top and border bottom were also set, so this led to the wrong style index
Thanks for this Andreas. The patch looks good, applied with a few minor tweaks in r1539837.