Skip to content

Commit 4bd6587

Browse files
committed
Update OoxmlReader.java
1 parent 58c1b6a commit 4bd6587

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/main/java/com/github/pjfanning/xlsx/impl/ooxml/OoxmlReader.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2424
import com.github.pjfanning.xlsx.StreamingReader;
2525
import com.github.pjfanning.xlsx.exceptions.CheckedReadException;
2626
import com.github.pjfanning.xlsx.exceptions.MissingSheetException;
27-
import com.github.pjfanning.xlsx.exceptions.OpenException;
2827
import org.apache.poi.ooxml.POIXMLException;
2928
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
3029
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -73,13 +72,13 @@ public class OoxmlReader extends XSSFReader {
7372
* @param pkg The package this poi filesystem reader will use
7473
* @param strictOoxmlChecksNeeded whether to perform strict OOXML checks
7574
* @throws IOException if an error occurs while reading the package
76-
* @throws OpenXML4JException if an error occurs while parsing the package
77-
* @throws POIXMLException if the package is invalid
75+
* @throws CheckedReadException if an error occurs while reading the package
76+
* @throws OpenXML4JException if there is an error parsing the OpenXML file
7877
*/
7978
@Internal
8079
public OoxmlReader(StreamingReader.Builder builder,
8180
OPCPackage pkg, boolean strictOoxmlChecksNeeded)
82-
throws IOException, CheckedReadException, OpenXML4JException, POIXMLException {
81+
throws IOException, CheckedReadException, OpenXML4JException {
8382
super(pkg, true);
8483

8584
PackageRelationship coreDocRelationship = this.pkg.getRelationshipsByType(
@@ -93,13 +92,17 @@ public OoxmlReader(StreamingReader.Builder builder,
9392
PackageRelationshipTypes.STRICT_CORE_DOCUMENT).getRelationship(0);
9493

9594
if (coreDocRelationship == null) {
96-
throw new POIXMLException("OOXML file structure broken/invalid - no core document found!");
95+
throw new CheckedReadException("OOXML file structure broken/invalid - no core document found!");
9796
}
9897
}
9998

10099
// Get the part that holds the workbook
101100
workbookPart = this.pkg.getPart(coreDocRelationship);
102-
ooxmlSheetReader = new OoxmlSheetReader(builder, workbookPart, strictOoxmlChecksNeeded);
101+
try {
102+
ooxmlSheetReader = new OoxmlSheetReader(builder, workbookPart, strictOoxmlChecksNeeded);
103+
} catch (InvalidFormatException e) {
104+
throw new CheckedReadException("invalid format", e);
105+
}
103106
}
104107

105108

0 commit comments

Comments
 (0)