Unit test to try to reproduce bug #62108 (currenly works though...)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1824451 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2018-02-16 11:47:24 +00:00
parent bd56cf68af
commit d0e9e4bc6d
1 changed files with 41 additions and 0 deletions

View File

@ -3252,4 +3252,45 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
wb.close();
}
/**
* Auto column sizing failed when there were loads of fonts with
* errors like ArrayIndexOutOfBoundsException: -32765
* TODO Get this to actually reproduce the bug...
*/
@Test
public void test62108() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFRow row = sheet.createRow(0);
// Create lots of fonts
XSSFDataFormat formats = wb.createDataFormat();
XSSFFont[] fonts = new XSSFFont[50000];
for (int i=0; i<fonts.length; i++) {
XSSFFont font = wb.createFont();
font.setFontHeight(i);
}
// Create a moderate number of columns, which use
// fonts from the start and end of the font list
final int numCols = 125;
for (int i=0; i<numCols; i++) {
XSSFCellStyle cs = wb.createCellStyle();
cs.setDataFormat(formats.getFormat("'Test "+i+"' #,###"));
XSSFFont font = fonts[i];
if (i%2==1) { font = fonts[fonts.length-i]; }
cs.setFont(font);
XSSFCell c = row.createCell(i);
c.setCellValue(i);
c.setCellStyle(cs);
}
// Do the auto-size
for (int i=0; i<numCols; i++) {
sheet.autoSizeColumn(i);
}
}
}