Articles in this section
Category / Section

How to add a table in a bookmark location?

1 min read

 

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

C#

//Create a new instance for word document

WordDocumentdocument = new WordDocument();

//Open the existing word document containing bookmark

document.Open("Bookmark_Template.doc");

//Create a new table

IWTabletable = 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

BookmarksNavigatorbk = 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

Dimdocument As New WordDocument()

'Open the existing word document containing bookmark

document.Open("Bookmark_Template.doc")

'Create a new table

Dimtable 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

Dimbk 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 the sample in the below link 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