Articles in this section
Category / Section

How to add a table in a bookmark location?

1 min read

DocIO provides support for adding a table into an existing bookmark. The following code snippet illustrates how to insert a table into the specified bookmark.

C#

// Create a new instance for Word document

WordDocument document = new WordDocument();

// Open the existing Word document containing a bookmark

document.Open("Bookmark_Template.doc");

// Create a new table

IWTable table = new WTable(document);

table.ResetCells(3, 2);

table.Rows[0].Cells[0].AddParagraph().AppendText("Sno");

table.Rows[0].Cells[1].AddParagraph().AppendText("Product");

table.Rows[0].IsHeader = true;

table.Rows[1].Cells[0].AddParagraph().AppendText("1.");

table.Rows[1].Cells[1].AddParagraph().AppendText("Essential DocIO");        

table.Rows[2].Cells[0].AddParagraph().AppendText("2.");

table.Rows[2].Cells[1].AddParagraph().AppendText("Essential Pdf");

// Create a new instance for Bookmark Navigator

BookmarksNavigator bk = new BookmarksNavigator(document);

// Move to the specified bookmark

bk.MoveToBookmark("Table");

// Insert the table into the specified bookmark location

bk.InsertTable(table);

document.Save("Sample.doc", FormatType.Doc);

 

VB

 

'Create a new instance for Word document

Dim document As New WordDocument()

'Open the existing Word document containing a bookmark

document.Open("Bookmark_Template.doc")

'Create a new table

Dim table As IWTable = New WTable(document)

table.ResetCells(3, 2)

table.Rows(0).Cells(0).AddParagraph().AppendText("Sno")

table.Rows(0).Cells(1).AddParagraph().AppendText("Product")

table.Rows(0).IsHeader = True

table.Rows(1).Cells(0).AddParagraph().AppendText("1.")

table.Rows(1).Cells(1).AddParagraph().AppendText("Essential DocIO")

table.Rows(2).Cells(0).AddParagraph().AppendText("2.")

table.Rows(2).Cells(1).AddParagraph().AppendText("Essential Pdf")

'Create a new instance for bookmark navigator

Dim bk As New BookmarksNavigator(document)

'Move to the specified bookmark

bk.MoveToBookmark("Table")

'Insert the table into the specified bookmark location

bk.InsertTable(table)

document.Save("Sample.doc", FormatType.Doc)

Please refer to the sample in the link below which illustrates the above:

http://help.syncfusion.com/samples/DocIO.Web/DocIOWebSamples/AddTableToBkMark/main.htm

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied