Skip to content

Fix XWPFTable row cannot insert to the last position of table#998

Merged
tonyqus merged 5 commits into
nissl-lab:masterfrom
GGJason:master
Mar 4, 2023
Merged

Fix XWPFTable row cannot insert to the last position of table#998
tonyqus merged 5 commits into
nissl-lab:masterfrom
GGJason:master

Conversation

@GGJason
Copy link
Copy Markdown
Contributor

@GGJason GGJason commented Jan 6, 2023

Fix XWPFTable row cannot insert to the last position of table.
The problem is in CT_Tbl.GetItems1Index method.
Because pos can never be equal to p in for loop, I add a statement to check if the index is -1 and pos == p after for loop. It means that the position is the end of the list.

for (int i = 0; i < items1ElementNameField.Count; i++)
{
    if (items1ElementNameField[i] == type)
    {
        if (pos == p)
        {
            //return itemsField[p] as T;
            index = i;
            break;
        }
        else
            pos++;
    }
}
// Check if the position should be the last position
if(index == -1 && pos == p) 
    index = items1Field.Count;

@tonyqus tonyqus added this to the NPOI 2.6.1 milestone Feb 27, 2023
@tonyqus
Copy link
Copy Markdown
Member

tonyqus commented Mar 4, 2023

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants