/** custom remove table method. but not removed in memory */ public static void removeAllTableDefinition(XSSFWorkbook workbook) { for (int i=0; i relationIds = new ArrayList(); PackageRelationshipCollection relationshipCollection = sheet.getPackagePart().getRelationships(); Iterator relationIterator =relationshipCollection.iterator(); while (relationIterator.hasNext()) { PackageRelationship relation = relationIterator.next(); if (relation.getRelationshipType().matches(".+table$")) {//direct match table type log.info(" remove table part {}:{}", relation.getId(), relation.getSourceURI()); relationIds.add(relation.getId()); } } for (String id: relationIds) { sheet.getPackagePart().removeRelationship(id); } CTWorksheet ct_sheet = sheet.getCTWorksheet(); CTTableParts ct_tableparts = ct_sheet.getTableParts(); if (ct_tableparts != null) { for (int j = (int) (ct_tableparts.getCount()-1); j >= 0; j--) { ct_tableparts.removeTablePart(j); } } } catch (InvalidFormatException ex) { log.error(ex.getMessage(), ex); } } }