if(! worksheet.isSetTableParts()) {
worksheet.addNewTableParts();
}
CTTableParts tblParts = worksheet.getTableParts();
CTTablePart tbl = tblParts.addNewTablePart();
// Table numbers need to be unique in the file, not just
// unique within the sheet. Find the next one
int tableNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType()).size() + 1;
XSSFTable table = (XSSFTable)createRelationship(XSSFRelation.TABLE, XSSFFactory.getInstance(), tableNumber);
tbl.setId(table.getPackageRelationship().getId());
tables.put(tbl.getId(), table);
return table;
}