diff --git a/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java b/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java index fa3b03882b..65d1e3d693 100644 --- a/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java +++ b/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java @@ -44,6 +44,7 @@ import org.apache.poi.hwpf.extractor.WordExtractor; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; import org.apache.poi.poifs.filesystem.DirectoryEntry; @@ -131,7 +132,7 @@ public class ExtractorFactory { return createExtractor(new POIFSFileSystem(inp)); } if(POIXMLDocument.hasOOXMLHeader(inp)) { - return createExtractor(OPCPackage.open(f.toString())); + return createExtractor(OPCPackage.open(f.toString(), PackageAccess.READ)); } throw new IllegalArgumentException("Your File was neither an OLE2 file, nor an OOXML file"); } finally { diff --git a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java index ba3844ae0e..6f43ba126b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java +++ b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java @@ -195,13 +195,15 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor // add textboxes if (includeTextBoxes){ - XSSFDrawing drawing = sheet.createDrawingPatriarch(); - for (XSSFShape shape : drawing.getShapes()){ - if (shape instanceof XSSFSimpleShape){ - String boxText = ((XSSFSimpleShape)shape).getText(); - if (boxText.length() > 0){ - text.append(boxText); - text.append('\n'); + XSSFDrawing drawing = sheet.getDrawingPatriarch(); + if (drawing != null) { + for (XSSFShape shape : drawing.getShapes()){ + if (shape instanceof XSSFSimpleShape){ + String boxText = ((XSSFSimpleShape)shape).getText(); + if (boxText.length() > 0){ + text.append(boxText); + text.append('\n'); + } } } }