Created attachment 27541 [details] The problematic spreadsheet I have a spreadsheet which has been created with Apache POI and edited in Excel. (See attached.) When I open it with POI and attempt to add a comment to the first sheet, I get the following error message: org.apache.poi.openxml4j.exceptions.InvalidOperationException: A part with the name '/xl/comments1.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] Tested against 3.8-beta4, with the following code: public static void bugtest() { FileInputStream inp = null; try { inp = new FileInputStream(new File(OUTPUT_FOLDER, "comments-notworking.xlsx")); Workbook wb = WorkbookFactory.create(inp); Sheet s = wb.getSheet("comments"); Cell c = s.getRow(0).getCell(0); CreationHelper factory = wb.getCreationHelper(); Drawing drawing = s.createDrawingPatriarch(); ClientAnchor anchor = factory.createClientAnchor(); anchor.setCol1(0); anchor.setCol2(4); anchor.setRow1(0); anchor.setRow2(1); Comment excelComment = drawing.createCellComment(anchor); excelComment.setString(factory.createRichTextString("I like this cell. It's my favourite.")); excelComment.setAuthor("Bob T. Fish"); c.setCellComment(excelComment); } catch (Exception e) { e.printStackTrace(); } finally { try { inp.close(); } catch (Exception e) {} } }
Fixed in r1174048. We try to give the new comments part the same ID as the sheet has, but if someone has already claimed that name then we just take the next available one