question

PrakruthiKV-5720 avatar image
0 Votes"
PrakruthiKV-5720 asked ·

How to dynamically append rows in OpenXML document using C#

Report generated in word format has multiple tables. One of the table data is distributed in many pages, which has column names (group header) in each page.

When some of the rows are deleted from current table and if we click on "delete" button, we need to append the rows from next page to current page until the current page is full, without their columns i.e., columns should sit at the start of each page when the rows are present. Columns should not be moved up along with rows. Only row data should get appended.

How can we achieve this using "DocumentFormat.OpenXml" extensions in C#?

dotnet-csharp
· 3
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @PrakruthiKV-5720,
>>without their columns i.e., columns should sit at the start of each page when the rows are present. Columns should not be moved up along with rows. Only row data should get appended.
According to my understanding, you want to append the row data of the next page to the previous page, while the column names of the first row remain unchanged.
Do multiple tables have the same columns and column names? Please describe the situation in more detail.
And here are some code examples in these threads you can refer to.
OpenXML append rows to an existing table in Word
Add a row to an existing table in a Word Document (open XML)
Best Regards,
Daniel Zhang


0 Votes 0 ·

Hi DanielZhang-MSFT,

It is a single table, but it is split across pages as the rows are more.

Distributed table has same columns/table headers. When, one page table rows are deleted and we press 'Delete' button, next page table is moving. Instead, only the next table rows should move and append in the empty space, keeping the table header in next page only, so that the remaining rows will appear in the next page.

Regards,
Prakruthi

0 Votes 0 ·

Hi @PrakruthiKV-5720,
You can try to clone the rows and use append method to insert new row wiht data on the last line of each page.
Some code examples in the links below you can refer to.
Insert a table into a word processing document (Open XML SDK)
Add rows to a table dynamically in existing word document using OpenXml
Best Regards,
Daniel Zhang


0 Votes 0 ·

0 Answers