Created attachment 25840 [details] patch for StylesTable to return size of correct (?) list XSSFWorkbook implementation of wb.getNumCellStyles returns incorrect value, usually just "1", while wb.getCellStyleAt() still finds all the styles (...before IndexOutOfBounds hits :) I inspected the code, and finally patched StylesTable to return size of different list, as shown in attached patch. Seems to work, although I would suggest that someone more familiar with XSSF internals checks through the code. I got quite confused about styleXfs vs. xfs...
Thanks for investigating this Something similar applied in r982269, along with unit tests which show that we correct get the right number of styles as they're added, and that we can't read off the end of the list any more