View | Details | Raw Unified | Return to bug 52836
Collapse All | Expand All

(-)a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (+8 lines)
Lines 49-54 import org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException; Link Here
49
import org.apache.poi.openxml4j.opc.PackagePart;
49
import org.apache.poi.openxml4j.opc.PackagePart;
50
import org.apache.poi.openxml4j.opc.PackageRelationship;
50
import org.apache.poi.openxml4j.opc.PackageRelationship;
51
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
51
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
52
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
52
import org.apache.poi.openxml4j.opc.TargetMode;
53
import org.apache.poi.openxml4j.opc.TargetMode;
53
import org.apache.poi.poifs.crypt.HashAlgorithm;
54
import org.apache.poi.poifs.crypt.HashAlgorithm;
54
import org.apache.poi.ss.SpreadsheetVersion;
55
import org.apache.poi.ss.SpreadsheetVersion;
Lines 536-541 public class XSSFSheet extends POIXMLDocumentPart implements Sheet { Link Here
536
        
537
        
537
        //drawingNumber = #drawings.size() + 1
538
        //drawingNumber = #drawings.size() + 1
538
        int drawingNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.DRAWINGS.getContentType()).size() + 1;
539
        int drawingNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.DRAWINGS.getContentType()).size() + 1;
540
        try {
541
            // bug 52836: if there are some stray parts left over from badly formatted files, we should skip those
542
            getPackagePart().getPackage().removePart(PackagingURIHelper.createPartName(XSSFRelation.DRAWINGS.getFileName(drawingNumber)));
543
        } catch (InvalidFormatException e) {
544
            // TODO Auto-generated catch block
545
            e.printStackTrace();
546
        }
539
        RelationPart rp = createRelationship(XSSFRelation.DRAWINGS, XSSFFactory.getInstance(), drawingNumber, false);
547
        RelationPart rp = createRelationship(XSSFRelation.DRAWINGS, XSSFFactory.getInstance(), drawingNumber, false);
540
        XSSFDrawing drawing = rp.getDocumentPart();
548
        XSSFDrawing drawing = rp.getDocumentPart();
541
        String relId = rp.getRelationship().getId();
549
        String relId = rp.getRelationship().getId();

Return to bug 52836