xceedsoftware / DocX

Fast and easy to use .NET library that creates or modifies Microsoft Word files without installing Word.
Other
1.78k stars 475 forks source link

Inserting new table rows does not update paragraphs if document is loaded #434

Open Skyswimsky opened 2 years ago

Skyswimsky commented 2 years ago

Hi!

Following error: If you load a Document and insert rows in a table, the paragraph count isn't updating. Instead you have to load the document anew.

I've provided an example code that demonstrates the issue below.

using (DocX document = DocX.Create(copyPath))
{
    document.InsertTable(3, 3);
    Console.WriteLine("Paragraphs after table creation and doc creation: " + document.Paragraphs.Count);
    document.Save();
}

using (DocX document = DocX.Load(copyPath))
{
    foreach (var table in document.Tables)
    {
        Row row = table.Rows[0];
        table.InsertRow(row);
    }
    document.Save();

    Console.WriteLine("Paragraphs after row insertion and doc loading: " + document.Paragraphs.Count);
}

using (DocX document = DocX.Load(copyPath))
{
    Console.WriteLine("Paragraphs after doc loading no row insertion: " + document.Paragraphs.Count);
}

I've attached a screenshot for a visual aid of what I meant: docXBugTableLoadParagraph

XceedBoucherS commented 2 years ago

Hi, Thank you for bringing this to our attention. It will be fixed in v2.4. Have a nice day.