How to add tables to an existing document

I have a document that already has some content in it and I want to add table just after the end of the content.

document.AddSection() starts from the new page. even when I use :  section.BreakCode = SectionBreakCode.NoBreak;

How can this be implemented . I need to add tables and paragraph not to start from next page but to just continue from where the existing content stops.

Thanks for prompt response.

1 Reply

MR Manikandan Ravichandran Syncfusion Team February 27, 2020 02:26 PM UTC

Hi Adepoju,

Thank you for contacting Syncfusion support.

From the given details, we suspect that, your requirement is to add the table next to the paragraph not in new page.
If your adding the table in new section, the table will preserve in new page. If you want to preserve the table continuously, you can use below code example.

 
//Adds the new section to the document
section = document.AddSection();
//Sets a section break
section.BreakCode = SectionBreakCode.NoBreak;
//Adds a table to created section
WTable table
= section.AddTable();

In another way, you can achieve this, by adding the table in owner text body of the last paragraph.

Based on these two ways, we have prepared the sample and it can be downloaded from the following link.
Procedure -1:.
https://www.syncfusion.com/downloads/support/forum/151947/ze/CreateWordSample1773750096
Procedure -2:
https://www.syncfusion.com/downloads/support/forum/151947/ze/CreateWordSample1482132599

In this sample, we have done the followings.
1. Loaded the input word document.
2. Created the new table which is going to be insert in the document.
Procedure -1:
3. Added the table in new section with no break code
Procedure -2:
3. Added the table in the owner text body of the paragraph (next to the paragraph).
4. Saved the word document.

If you think, we misunderstood any of your requirement, then kindly provide us modified sample of the above along with input template Word document, screenshot/output Word document of the expected result which will helpful to provide you the appropriate solution at the earliest

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran


Loader.
Up arrow icon