Bug 65023

Summary: addNewCol is untested and does not work
Product: POI Reporter: Paula Muldoon <pmuldoon>
Component: XWPFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X 10.1   

Description Paula Muldoon 2020-12-22 10:52:43 UTC
In src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java, the method addNewCol() is unused and also untested in the Apache POI project. In the course of writing a unit test for it, I discovered that the implementation does not work as it creates new rows instead of using the existing ones.

I am writing a fix for it and will submit a PR via GitHub. I will add a comment to this report once I have done so - I need to submit this report first in order to get an issue number.

Test to reproduce the issue:

    @Test
    public void testAddNewCol() throws IOException {
        XWPFDocument doc = new XWPFDocument();
        XWPFTable table = doc.createTable(2, 4);
        table.addNewCol();
        XWPFTableRow lastRow = table.tableRows.get(table.tableRows.size() - 1);

        int expected = 5;
        int actual = lastRow.getTableCells().size();
        assertEquals(expected, actual);
        doc.close();
    }
Comment 1 Paula Muldoon 2020-12-22 14:39:22 UTC
Pull request on GitHub: https://github.com/apache/poi/pull/212
Comment 2 PJ Fanning 2020-12-25 10:26:14 UTC
Merged Github PR using r1884794