diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRelation.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRelation.java index 04ec265eaf..712e874267 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRelation.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRelation.java @@ -286,17 +286,29 @@ public final class XSSFRelation extends POIXMLRelation { ); public static final XSSFRelation MACRO_SHEET_BIN = new XSSFRelation( - "application/vnd.ms-excel.macrosheet+xml", + "application/vnd.ms-excel.macrosheet", "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet", "/xl/macroSheets/sheet#.bin" ); + public static final XSSFRelation MACRO_SHEET_XML = new XSSFRelation( + "application/vnd.ms-excel.macrosheet+xml", + "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet", + "/xl/macroSheets/sheet#.xml" + ); + public static final XSSFRelation INTL_MACRO_SHEET_BIN = new XSSFRelation( - "application/vnd.ms-excel.intlmacrosheet+xml", + "application/vnd.ms-excel.intlmacrosheet", "http://schemas.microsoft.com/office/2006/relationships/xlIntlMacrosheet", "/xl/macroSheets/sheet#.bin" ); + public static final XSSFRelation INTL_MACRO_SHEET_XML = new XSSFRelation( + "application/vnd.ms-excel.intlmacrosheet+xml", + "http://schemas.microsoft.com/office/2006/relationships/xlIntlMacrosheet", + "/xl/macroSheets/sheet#.xml" + ); + public static final XSSFRelation DIALOG_SHEET_BIN = new XSSFRelation( null,//TODO: figure out what this should be? "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet", diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 4522797792..a9240a6f0a 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -68,6 +68,7 @@ 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.PackageRelationship; +import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.util.ZipSecureFile; import org.apache.poi.poifs.crypt.Decryptor; @@ -3841,6 +3842,18 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { readByCommonsCompress(temp_excel_poi_decrypt); } + @Test + void getMacrosheet() throws IOException, InvalidFormatException { + try (XSSFWorkbook wb = openSampleWorkbook("xlmmacro.xlsm")) { + PackageRelationshipCollection prc = wb.getPackagePart().getRelationships(); + assertNotNull(prc); + assertEquals(6, prc.size()); + PackageRelationshipCollection prc2 = prc.getRelationships(XSSFRelation.MACRO_SHEET_XML.getRelation()); + assertNotNull(prc2); + assertEquals(1, prc2.size()); + } + } + private static void readByCommonsCompress(File temp_excel_poi) throws IOException { /* read by commons-compress*/ try (ZipFile zipFile = new ZipFile(temp_excel_poi)) { diff --git a/test-data/spreadsheet/xlmmacro.xlsm b/test-data/spreadsheet/xlmmacro.xlsm new file mode 100644 index 0000000000..5cae057879 Binary files /dev/null and b/test-data/spreadsheet/xlmmacro.xlsm differ