Created attachment 23953 [details] sample workbook that POI 3.5-beta6 cannot open Problem: I created a simple xlsx file (Tried using both Excel 2008/Mac and 2007/Windows) by doing the following: 1) Create new workbook 2) Add a shape to workbook (Insert->Picture->Shape) 3) Right-click the shape, select Hyperlink... 4) Select "Document" (or "Place in this Document") as the link type 5) Click "Locate..." choose "Cell Reference", then select a cell on a sheet 6) Save file (I will attach this workbook to the bug) Try to read the xlsx file with POI (3.5-beta6), using the following code: XSSFWorkbook wb = new XSSFWorkbook("test-hyperlink.xlsx"); Get the following exception: Exception in thread "main" org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: A segment shall not hold any characters other than pchar characters. [M1.6] at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:152) at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:163) at org.apache.poi.util.TestLoad.main(TestLoad.java:49) Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: A segment shall not hold any characters other than pchar characters. [M1.6] at org.apache.poi.openxml4j.opc.PackagePartName.checkPCharCompliance(PackagePartName.java:370) at org.apache.poi.openxml4j.opc.PackagePartName.throwExceptionIfPartNameHaveInvalidSegments(PackagePartName.java:270) at org.apache.poi.openxml4j.opc.PackagePartName.throwExceptionIfInvalidPartUri(PackagePartName.java:185) at org.apache.poi.openxml4j.opc.PackagePartName.<init>(PackagePartName.java:83) at org.apache.poi.openxml4j.opc.PackagingURIHelper.createPartName(PackagingURIHelper.java:443) at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:234) at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:244) at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:244) at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:150) ... 2 more
Fixed in r793280 POI didn't properly process OPC packages containing relationships with targets starting with '#'. In your case the problem was caused by a hyperlink relationship attached to the sheet drawing: <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="#Sheet1!A1"/> The '#' character indicates an internal target (e.g. cell region). Regards, Yegor