When trying to copy over cell styles from an old Excel file, after writing 32357 cells, the font disappears and when finding the root of the problem, I came across the error that it's throwing this:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -32768
at java.util.ArrayList.elementData(ArrayList.java:400)
at java.util.ArrayList.get(ArrayList.java:413)
at org.apache.poi.xssf.model.StylesTable.getFontAt(StylesTable.java:210)
at org.apache.poi.xssf.usermodel.XSSFCellStyle.getFont(XSSFCellStyle.java:561)
at Compare.writeRows(Compare.java:415)
at Compare.main(Compare.java:44)
and to copy over the CellStyle
from the old Excel file, I did this:
XSSFCellStyle style = workbook.createCellStyle();
style.cloneStyleFrom(oldCell.getCellStyle());
newCell.setCellStyle(style);
style.getFont(); //throws error here
newCell.setCellType(oldCell.getCellType());
But I don't understand why it's doing that because when I do rows.get(2506).getCell(2).getCellStyle().getFont()
it returns an XSSFFont
object (the XSSFFont
that style.getFont()
should be returning) and doesn't throw an Exception
.
I would really appreciate if someone could help me with this problem.
Apache POI is limited to 32767 Fonts per workbook
You will need to find a way to reuse the fonts and cell styles.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.