Summary: | Macrosheet not found in xslm sheets | ||
---|---|---|---|
Product: | POI | Reporter: | 1umos |
Component: | XSSF | Assignee: | POI Developers List <dev> |
Status: | NEEDINFO --- | ||
Severity: | major | ||
Priority: | P2 | ||
Version: | 5.2.3-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: | xlsm file containing a empty macrosheet that reproduces the problem |
Description
1umos
2023-05-22 15:01:04 UTC
Have you tried getRelationshipsByType("http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet") - from a quick check of the POI code, getRelationshipsByType expects strings like this - not 'content types' 1umos - is this you? https://stackoverflow.com/questions/76306947/how-to-get-xlm-macro-sheet-from-excel-with-apache-poi-xssfworkbook Seems similar but seems to suggest that you can get relationships of this type - while maybe running into issues removing them. I tested your xlsm file and this code seems to get the macrosheet part String relType = "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet"; PackageRelationshipCollection prc = workbook.getPackagePart().getRelationships(); assertNotNull(prc); assertEquals(6, prc.size()); PackageRelationshipCollection prc2 = prc.getRelationships(relType); assertNotNull(prc2); assertEquals(1, prc2.size()); workbook.getPackage() checks the wrong relationships - you need workbook.getPackagePart().getRelationships() (In reply to PJ Fanning from comment #3) > I tested your xlsm file and this code seems to get the macrosheet part > > String relType = > "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet"; > PackageRelationshipCollection prc = > workbook.getPackagePart().getRelationships(); > assertNotNull(prc); > assertEquals(6, prc.size()); > PackageRelationshipCollection prc2 = > prc.getRelationships(relType); > assertNotNull(prc2); > assertEquals(1, prc2.size()); > > workbook.getPackage() checks the wrong relationships - you need > workbook.getPackagePart().getRelationships() Thanks, I get macrosheets part like this, but if I try to removeRelationship then document doesn't open. Do you have a solution for that? And yes stackoverflow question is mine. |