Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Mar 4, 2023

Conversation

GGJason
Copy link
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
Member

tonyqus commented Mar 4, 2023

LGTM

@tonyqus tonyqus merged commit 94f3092 into nissl-lab:master Mar 4, 2023
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