I used the XSSFWorkbook class to generate an excel file Workbook book = new XSSFWorkbook()
To optimize the application, I decided to switch to SXSSFWorkbook SXSSFWorkbook book = new SXSSFWorkbook()
As it turns out, the SXSSFSheet
that provides SXSSFWorkbook
does not have a createTable(AreaReference)
method, so I used the following:
XSSFTable table = ((SXSSFWorkbook) book).getXSSFWorkbook().getSheetAt(0).createTable(reference);
And now, when generating a file, I get errors, despite the fact that i can interact with the file itself and the table:
Repaired Records: Table from /xl/tables/table1.xml part (Table)
If i replace SXSSFWorkbook
with XSSFWorkbook
and the table creation method with XSSFTable table = ((XSSFSheet) sheet).createTable(reference);
, then there are no errors
This is what the method itself looks like:
public static void createTable(Workbook book,
sheet sheet,
stringname,
int pRowStart,
int pColStart,
int pRowEnd,
int pColEnd) {
AreaReference reference = book.getCreationHelper().createAreaReference(
new CellReference(pRowStart, pColStart), new CellReference(pRowEnd, pColEnd)
);
XSSFTable table = ((SXSSFWorkbook) book).getXSSFWorkbook().getSheetAt(0).createTable(reference);
// XSSFTable table = ((XSSFSheet) sheet).createTable(reference);
if (table.getArea() != null) {
table.getCTTable().addNewAutoFilter().setRef(table.getArea().formatAsString());
}
}