We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

WordDocument accessing table via bookmark

Thread ID:

Created:

Updated:

Platform:

Replies:

131945 Aug 4,2017 10:52 AM UTC Aug 10,2017 09:49 AM UTC WPF 3
loading
Tags: DocIO
Tim
Asked On August 4, 2017 10:52 AM UTC

Hello. I'm trying to access the table in a Word document by bookmark. I can access it just fine but when I change some text in a table or try to add rows, there is no change visible in the saved document. I'm attaching the code which accesses the table.

Vijay Ramachandran [Syncfusion]
Replied On August 7, 2017 08:48 AM UTC

Hi Tim,

Thank you for contacting Syncfusion support.

On analyzing further with the given details, we found that you have used GetBookmarkContent() method to get the particular bookmark text body. Then you have finds the table and added the text into each cell of this table.

Since the GetBookmarkContent() method is used to get the bookmark content as cloned text body, the changes made in the cloned text body wasn’t reflected in original Word document. If your requirement is changing the Word document content means, then kindly replace the existing text body with new text body(text added to each cell) by using our BookmarksNavigator.ReplaceBookmarkContent() API. Kindly add the below highlighted code in your sample to resolve the reported problem.
 
    var part = bookmarkNavigator.GetBookmarkContent();
   
if(part.BodyItems.FirstItem is IWTable table)
       
foreach(WTableRow row in table.Rows)
           
foreach (WTableCell cell in row.Cells)
               
foreach (WParagraph paragraph in cell.Paragraphs)
                    paragraph.Text =
"TEST";

    
bookmarkNavigator.ReplaceBookmarkContent(part); 

We have also prepared demo sample for this scenario, please find the sample from here and let us know if it helps.

Regards,
Vijay R
 


Tim
Replied On August 10, 2017 09:37 AM UTC

It works now. Thanks for your help.


Sethumanikkam Yogendran [Syncfusion]
Replied On August 10, 2017 09:49 AM UTC

Hi Tim,

Thank you for your update.

We are happy to hear that the provided sample resolved your requirement. Please let us know if you need any further assistance on this. We will be happy to assist you as always.

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;