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. Image for the cookie policy date

Problem filling a table

hi,
i have a question and i would like to found the problem and the correction ,
i have two type of document doc_test1 and doc_test2 (contain table in bookmark)
i want just to put data in the table, but i have two type of result !!!
y found in attach the result_test1 and result_test2.

i use this code:

Dim a As WordDocument = New WordDocument(chemin + "\testword\doc_test_1.doc", FormatType.Doc)
        Dim bknav As BookmarksNavigator = New BookmarksNavigator(a)
        bknav.MoveToBookmark("tableauObligProprio")
        Dim tbp As TextBodyPart = bknav.GetBookmarkContent()
        Dim table As WTable = Nothing
        For Each element As Syncfusion.DocIO.DLS.IEntity In tbp.BodyItems
            If TypeOf element Is WTable Then
                table = CType(element, WTable)
                Exit For
            End If
        Next
        For Each cell As WTableCell In table.LastRow.Cells
            If cell.GetCellIndex = 0 Then
                cell.LastParagraph.Text = "1"
            End If
            If cell.GetCellIndex = 1 Then
                cell.LastParagraph.Text = "entree"
                '' faut tester aussi l'insertion d'image
                cell.LastParagraph.AppendBookmarkStart("xx")
                cell.LastParagraph.AppendBookmarkEnd("xx")
                InsererFichier(a, "C:\Users\emaayadi\Desktop\image\index.jpeg", "xx")
            End If
            If cell.GetCellIndex = 2 Then cell.LastParagraph.Text = "lot"
            If cell.GetCellIndex = 3 Then cell.LastParagraph.Text = "etage"
            If cell.GetCellIndex = 4 Then cell.LastParagraph.Text = "visite"
            If cell.GetCellIndex = 5 Then cell.LastParagraph.Text = "justificatif"
        Next
        bknav.ReplaceBookmarkContent(tbp)


can i know the difference between the two document,
and can i have the good code work for the two type document

thanks

Attachment: sample_e20390a1.zip

10 Replies

MJ Mohanaselvam Jothi Syncfusion Team May 29, 2019 02:46 AM

Hi AtliDev,

Thank you for contacting Syncfusion support.

We can reproduce the reported content preservation problem when replacing bookmark content in the given Word document (“doc_test_2.doc”) and the fix for the issue will be included in our upcoming release 2019 Volume 2 Service pack 1, which is expected to be rolled out in end of July, 2019 tentatively.

Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 



AT AtliDev May 29, 2019 03:47 AM

thanks for reply,
can u create a feedback for this problem?

regards.



MJ Mohanaselvam Jothi Syncfusion Team May 30, 2019 06:03 AM

Hi AtliDev,

Thank you for your update.

You can track the status of bug report in the below feedback portal link:
https://www.syncfusion.com/feedback/6633/bookmark-not-replaced-properly-in-the-word-document

Regards,
Mohanaselvam J


AT AtliDev May 31, 2019 04:26 AM

hi,
thanks for the creation ,
can i know just the difference between the two table ,
or just  having bookmark start or end out of table  to get the right result ?

thanks


VA Vijayasurya Anandhan Syncfusion Team May 31, 2019 05:30 AM

Hi AtliDev,

Thank you for your update.

Please find the details for your queries below as follows:


 
Query 
Detail 
can I know just the difference between the two table,  
On further analyzing the documents provided from your side, in the first document (doc_test_1.doc), bookmark start is at the outer of the table. But in the second document (doc_test_2.doc), bookmark start is at the first paragraph in the first cell of the table and the bookmark end is at the second row of the table which causes the issue.

In the UI level, both documents will look the same but in the file level representation, we can able to see these difference.

This difference in document causes some issue when replacing bookmark content on this scenario. As promised earlier, we will include the fix for the reported issue in our upcoming 2019 Volume 2 SP1 release which is estimated to be available at the end of July tentatively.

 
or just having a bookmark start or end out of the table to get the right result? 
Yes, Like first document (doc_test_1.doc), reposition the bookmark to start and end of the table for the second document (doc_test_2.doc), which will give you the correct result.  


Please let us know if you have any queries.




Regards,
Vijayasurya A



AT AtliDev August 1, 2019 06:47 AM

Hi, 

We are now in august and still waiting for a fix ..
Any news please ?

thanks.


PR Poorani Rajendran Syncfusion Team August 1, 2019 09:16 PM

Hi AtliDev,

Thank you for your update.

Due to some internal concerns, our 2019 Volume 2 Service Pack 1 release was delayed. So, we have scheduled our 2019 Volume 2 Service Pack 1 release at the end of August, tentatively.

Please let us know if you have any other questions.

Regards,
Poorani Rajendran



AT AtliDev November 15, 2019 02:05 AM

hi, 
thank you for helping.
i have a problem to modify cell of table.
( my table in surrounded by two bookmark tab_zpso and ptab_zpso , so when i do modification for the content of tab_zpso like deleting column , the table doesn't change. 
more of that , i can't filling the cell of table ) 
is the problem caused by the second ptab_zpso ??
can i have solution of this issu with out changing my document.

i attach a sample document for test.
the code that i use : 

        Dim a As WordDocument = New WordDocument(chemin + "\testword\testzpso\sti_zpsoErbA.doc", FormatType.Doc)
        Dim bknav As BookmarksNavigator = New BookmarksNavigator(a)
        bknav.MoveToBookmark("tab_ZpsoA0000")
        Dim tbp As TextBodyPart = bknav.GetBookmarkContent()

        Dim table As WTable = Nothing

        For Each element As Syncfusion.DocIO.DLS.IEntity In tbp.BodyItems
            If TypeOf element Is WTable Then
                table = CType(element, WTable)
                Exit For
            End If
        Next

        '' delete column from table
        For Each row As WTableRow In table.Rows
            row.Cells.RemoveAt(1)
        Next

        bknav.ReplaceBookmarkContent(tbp)
        bknav.MoveToBookmark("tab_ZpsoA0000")
        tbp = bknav.GetBookmarkContent()


        '' after modif get a other time the table
        For Each element As Syncfusion.DocIO.DLS.IEntity In tbp.BodyItems
            If TypeOf element Is WTable Then
                table = CType(element, WTable)
                Exit For
            End If
        Next

        '' modification cell of table
        For Each cell As WTableCell In table.LastRow.Cells
            If cell.GetCellIndex = 0 Then
                cell.LastParagraph.Text = "1"
            End If
            If cell.GetCellIndex = 1 Then
                cell.LastParagraph.Text = "entree"             
            End If
            If cell.GetCellIndex = 2 Then cell.LastParagraph.Text = "lot"
            If cell.GetCellIndex = 3 Then cell.LastParagraph.Text = "etage"
            If cell.GetCellIndex = 4 Then cell.LastParagraph.Text = "visite"
            If cell.GetCellIndex = 5 Then cell.LastParagraph.Text = "justificatif"
        Next

        bknav.ReplaceBookmarkContent(tbp)

        a.Save(chemin + "\testword\testzpso\result.doc", FormatType.Doc)
        a.Close()



Thanks for help.

Attachment: sti_zpsoErbA_14ce71b.zip


PR Poorani Rajendran Syncfusion Team November 17, 2019 11:36 PM

Hi AtliDev,

Thank you for your update.

We can reproduce the reported problem while replacing bookmark content in Word document. We will validate on the reported problem and update you more details about this on 20th November, 2019.

Please let us know if you have any other questions.

Regards,
Poorani Rajendran



SB Suriya Balamurugan Syncfusion Team November 20, 2019 07:31 AM

Hi AtliDev,

Thank you for your patience.

We have confirmed that the reported “NullReferenceException issue while replacing bookmark content in Word document” is a defect and the fix for the issue will be included in our upcoming release 2019 Volume 4, which is expected to be rolled out in December, 2019.

Please let us know if you have any other questions.

Regards,
Suriya Balamurugan.


Loader.
Live Chat Icon For mobile
Up arrow icon