https://bz.apache.org/bugzilla/show_bug.cgi?id=68358

            Bug ID: 68358
           Summary: XWPFTable.addRow places copy of XWPFTableRow CTRow in
                    XWPFTable CTTbl
           Product: POI
           Version: 5.2.3-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XWPF
          Assignee: dev@poi.apache.org
          Reporter: aanettom...@gmail.com
  Target Milestone: ---

Here is sample code, which copy first row of table and populate it with some
text


    public static void sample(XWPFTable table) {
        final CTRow templateRow = (CTRow) table.getRow(0).getCtRow().copy();
        final XWPFTableRow tableRow = new XWPFTableRow((CTRow)
templateRow.copy(), table);
        tableRow.getCell(0).setText("Sample text"); // OK
        table.addRow(tableRow); // <-- cloned CTRow is copying
        tableRow.getCell(0).setText("Another sample text"); // <-- Modifying
old CTRow  
        // After writing document row still contain "Sample text"
    }

The problem is in method XWPFTable.addRow


   public void addRow(XWPFTableRow row) {
        ctTbl.addNewTr();
        ctTbl.setTrArray(getNumberOfRows() - 1, row.getCtRow()); // <-- copy
content of row CTRow
        tableRows.add(row); // <-- XWPFTableRow still points to own
row.getCtRow() and subsequent calls not affected final document
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to