Created attachment 28424 [details] Code for reproduce the problem mentioned above Hallo, I am not able to create a XSSFDrawing-Object. Each time I try to create one, I receive following error: Exception in thread "main" org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidOperationException: A part with the name '/xl/drawings/drawing2.xml' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12] at org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:260) at org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:233) at org.apache.poi.xssf.usermodel.XSSFSheet.createDrawingPatriarch(XSSFSheet.java:402) at ExcelFileCreationWithPOI.main(ExcelFileCreationWithPOI.java:28) Caused by: org.apache.poi.openxml4j.exceptions.InvalidOperationException: A part with the name '/xl/drawings/drawing2.xml' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12] at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:700) at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:664) at org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:252) ... 3 more Hereby I attach the code, which I have used. Please do notify me as soon as a solution is found. Thanks im advance! Regards Jimmy
Please attach the template that is used by your code snippet. Yegor
Created attachment 28816 [details] Template used by me for the code
Hallo Yegor, I am attached the template, that I have used in the code Kind regards Jimmy Chakkalakal
Works for me with current trunk (3.13-beta1 + some more changes), so it seems to have been fixed at some point.
sorry, I was wrong, it still happens when I use the correct sample file.
The file seems to have some unused/leftover content in the internal XML/ZIP, there is a xl/drawings/drawing2.xml which is not used. If you open the file in Excel/LibreOffice and re-save it, POI can work with it as expected...
Attached is another sample file which leads to the same exception
Created attachment 33383 [details] Another sample file which leads to the same exception
Created attachment 33553 [details] Potential patch for first error message I tried to have a go at this via the attached patch. If I simply try to avoid the error by forcefully removing the invalid part before creating the new one, creating a new sheet works, however when I try to clone the sheet, I get a different error: org.apache.poi.POIXMLException: org.apache.xmlbeans.XmlException: Element chartsheet@http://schemas.openxmlformats.org/spreadsheetml/2006/main is not a valid worksheet@http://schemas.openxmlformats.org/spreadsheetml/2006/main document or a valid substitution. at org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:174) at org.apache.poi.xssf.usermodel.XSSFWorkbook.cloneSheet(XSSFWorkbook.java:582) at org.apache.poi.xssf.usermodel.XSSFWorkbook.cloneSheet(XSSFWorkbook.java:1) at org.apache.poi.xssf.usermodel.TestXSSFBugs.test52836(TestXSSFBugs.java:2977) Caused by: org.apache.xmlbeans.XmlException: Element chartsheet@http://schemas.openxmlformats.org/spreadsheetml/2006/main is not a valid worksheet@http://schemas.openxmlformats.org/spreadsheetml/2006/main document or a valid substitution. at org.apache.xmlbeans.impl.store.Locale.autoTypeDocument(Locale.java:329) at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1280) at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1264) at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345) at org.apache.poi.POIXMLTypeLoader.parse(POIXMLTypeLoader.java:92) at org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument$Factory.parse(Unknown Source) at org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:172) ... 26 more
*** Bug 60255 has been marked as a duplicate of this bug. *** Fixed in 3.16-beta1