aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-08-13 15:32:03 +0000
committerPJ Fanning <fanningpj@apache.org>2022-08-13 15:32:03 +0000
commit839594b73e201df99850dc07ab726893bf36d156 (patch)
treebb57bf168cca4bf022048f81055f507dcae41304 /poi-ooxml
parent7301e841c7acde26553057579449d786014c2807 (diff)
downloadpoi-839594b73e201df99850dc07ab726893bf36d156.tar.gz
poi-839594b73e201df99850dc07ab726893bf36d156.zip
[bug-66212] try to remove package part for table when removing table
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903394 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
index 83aa926529..1459bc872d 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
@@ -36,10 +36,7 @@ import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException;
-import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
-import org.apache.poi.openxml4j.opc.TargetMode;
+import org.apache.poi.openxml4j.opc.*;
import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.FormulaShifter;
@@ -4315,6 +4312,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
removeRelation(getRelationById(toDelete.getKey()), true);
tables.remove(toDelete.getKey());
toDelete.getValue().onTableDelete();
+ OPCPackage opcPackage = getWorkbook().getPackage();
+ PackagePart packagePart = t.getPackagePart();
+ if (packagePart != null && opcPackage.containPart(packagePart.getPartName())) {
+ opcPackage.removePart(packagePart);
+ }
}
}