Adding tables at a bookmark location

Does anyone have an example of how to add a table at a bookmark. I had working code in v4.2 and have since recently upgraded.

Now I am have difficulties correcting the code.

Old code was:
IWTable table = (WTable) bookmark.InsertParagraphItem(ParagraphItemType.Table);
BuildTable(table);

The problems I see:
The enum ParagraphItemType.Table no longer appears in the current build.

bookmark.GetBookmarkContent() brings back a TextBodyPart. I am unsure if I can add tables to this object.

Any starting tips?

Thanks,
Jason





1 Reply

MW Melba Winshia Syncfusion Team October 17, 2007 01:31 PM UTC

Hi Jason,

We regret for the delayed response.

You can add a table at a bookmark location by getting the table in the TextBodyPart and replacing the bookmark by using this TextBodyPart.

[C#]

BookmarksNavigator bn = new BookmarksNavigator(doc);

//Select a table
TextBodyPart bodyPart = new TextBodyPart(replaceDoc);
bodyPart.BodyItems.Add(replaceDoc.LastSection.Body.Tables[0] as WTable);

//bn.DeleteBookmarkContent2();
bn.MoveToBookmark("bkmk_target");

//Replace with table
bn.ReplaceBookmarkContent(bodyPart);

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

http://websamples.syncfusion.com/samples/DocIO.Windows/69016/main.htm

Please try this and let me know if this helps.

Thanks,
Melba


Loader.
Up arrow icon