https://issues.apache.org/bugzilla/show_bug.cgi?id=51850

             Bug #: 51850
           Summary: Error adding comments to sheet
           Product: POI
           Version: 3.8-dev
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


Created attachment 27541
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27541
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) {}
        }
    }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to