简体   繁体   中英

How to add a table row to a word document using syncfusion in C#

I am very new to syncfusion and I am kind of stuck with this problem. I can easily populate a table if all of the rows and cells are created but I run into 'IndexOutofBounds' error once my data exceeds the number of rows in my template table. How can I add a row to a growing template table using Syncfusion in C#? I also would like to know how to handle the possiblity of the table growing to more than one page.

If you know the exact number of rows and columns , then you can utilize the below code to define rows and columns for a table.

IWTable table = document.LastSection.AddTable();
table.ResetCells(10, 4);

If you are not sure about the number of rows then you can use the below code to add a row dynamically.

table.AddRow();

Adding a row is an easy task. After adding the row the cell paragraphs have to be added and formatted. That was the error I was running into.

IWTable table = new IWTable();
table.AddRow(True);

table.Rows[0].Cells[0].AddParagraph().AddText("sample text");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM