Bug 65023 - addNewCol is untested and does not work
Summary: addNewCol is untested and does not work
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: unspecified
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2020-12-22 10:52 UTC by Paula Muldoon
Modified: 2020-12-25 10:26 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
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:

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

        int expected = 5;
        int actual = lastRow.getTableCells().size();
        assertEquals(expected, actual);
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