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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Replace a table

Thread ID:

Created:

Updated:

Platform:

Replies:

145109 Jun 6,2019 11:23 PM UTC Jul 15,2019 07:30 AM UTC ASP.NET Core - EJ 2 14
loading
Tags: DocIO
Pieter van Kampen
Asked On June 6, 2019 11:23 PM UTC

Hi,
I want to give my users a template document, that they can change and style, and then read the template, and enhance it with DocIO.

There are a number of bookmarks in the document. The bookmarks contain 
  • A header
  • Some text
  • A table
  • Some more text
Base on the data, the goal is for each individual bookmark part in the document:
  • Either to change the content of the table.
  • Or, to delete the whole part of header, text, and table.
My code fails at the first task:

             if (string.IsNullOrEmpty(bookmarkName)) return;
            //Move to the virtual cursor before the bookmark end location of the bookmark 
             BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
            bookmarkNavigator.MoveToBookmark(bookmarkName);
            if (bookmarkNavigator == null) return;
            //Gets the content for the current bookmark
            TextBodyPart textBodyPart = bookmarkNavigator.GetBookmarkContent();
            WTable table = null;
             var index = 0;
            foreach (Entity entity in textBodyPart.BodyItems)
            {
                if (entity is WTable)
                {
                    table = entity as WTable;
                    break;
                }
                index++;
            }
            if (table == null) return;
            ... process the table, add rows, columns, and change a number of cells
          
            textBodyPart.BodyItems.Insert(index, table); //add the new table
            bookmarkNavigator.ReplaceBookmarkContent(textBodyPart); //change the document

However, this leaves the document unchanged. I managed to do it with a second bookmark for just the table, but that complicates the template a lot by requiring all these extra bookmarks for each table. In that case, I used :
            textBodyPart.BodyItems.Add(table);
instead of the Insert, but this adds the table at the end of the bookmark, which is not what I want.

I hope you can help, because I am stuck.

Vijayasurya Anandhan [Syncfusion]
Replied On June 7, 2019 12:19 PM UTC

Hi Pieter,

Thank you for contacting Syncfusion support.

To meet your requirement, we have prepared a sample to modify the table in the Word document using BookmarksNavigator. Please find the sample from the below link:
http://www.syncfusion.com/downloads/support/forum/145109/ze/Sample_application168207457

If you are facing any problem while using this scenario at your end, we suspect that the problem might be due to the contents in the input Word document (file level) and the code snippets which used at your end. So, could you please provide us the modified sample of above along with the complete code snippets and input Word document. Thereby, we will check on your problem and will provide you the appropriate solution at the earliest.

Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to achieve your end requirements.
 


Regards,
Vijayasurya A
 


Pieter van Kampen
Replied On June 7, 2019 04:53 PM UTC

Hi Vijayasurya A,
that was very helpful.
There is definitely something strange going on, in combination with my document. I have modified the sample, to add a row and insert "New Cell" in that row, in two different tables in two bookmarks.

As you can see the row is added to the first table (in bookmark "One"), but not in the second (in bookmark "Two"). Even worse, the "New Cell" text is added twice to the last row of the first table.

However, if you click "Reverse" in my sample app, first bookmark Two is changed, than bookmark One, and now both have the proper change!

The document is a modified snippet of the full document, but the same happens when I use the full document. Reversing, e.g. changing the tables from the end of the document to the beginning also helps in my application. I have not tested that fully yet.

Regards

Pieter

Attachment: Sample_application168207457_pvk_96ede232.zip

Mohanaselvam  Jothi [Syncfusion]
Replied On June 10, 2019 10:09 AM UTC

Hi Pieter,

Thank you for your update.

We can reproduce the reported issue when replacing bookmark content in table. We will validate on this and will update you more details on 12th June, 2019.

Regarding I have not tested that fully yet:
If you face any problem at your end, please share us the code snippet along with the input Word document. You can also mail the files to our Syncfusion support through support@syncfusion.com with the forum Id as subject.

Please let us know if you have any other questions.

Regards,
Mohanaselvam J 


Vijayasurya Anandhan [Syncfusion]
Replied On June 13, 2019 02:30 PM UTC

Hi Pieter,

Thank you for your patience.

We confirmed that the suspected issue with “Bookmark gets removed when replacing bookmark content” is a defect. We have logged a defect report. The fix for this defect will be included in our upcoming 2019 Volume 2 SP1 release, which is estimated to be available in the end of July tentatively.


Note: The patch for the reported issue is estimated to be available on 4th July 2019. If you need patch for the issue, please let us know your current product version, which will be helpful for us to provide patch.
 


Regards,
Vijayasurya A


Pieter van Kampen
Replied On June 13, 2019 02:33 PM UTC

Hi Vijayasurya,
thanks. A patch would be great. I am using the .NET CORE platform 17.1.0.38.

Regards

Pieter

Vijayasurya Anandhan [Syncfusion]
Replied On June 14, 2019 06:59 AM UTC

Hi Pieter,

Thank you for your update.

As per your request, we will provide the patch for the reported issue with “Bookmark gets removed when replacing bookmark content” in the version 17.1.0.38, which is estimated to be available on 4th July 2019.

Please let us know if you have any queries.

Regards,
Vijayasurya A
 


Poorani Rajendran [Syncfusion]
Replied On July 4, 2019 03:23 PM UTC

Hi Pieter,

Thank you for your patience


We have fixed the reported
issue in replacing bookmark content in table
and the patch for the fix in the mentioned version 17.1.0.38 can be downloaded from the following link

Recommended approach - exe will perform automatic configuration
Please find the patch setup from below location: 
http://syncfusion.com/Installs/support/patch/17.1.0.38/958143/F145109/SyncfusionPatch_17.1.0.38_958143_7042019092631092_F145109.exe

Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment
Please find the patch assemblies alone from below location: 
http://syncfusion.com/Installs/support/patch/17.1.0.38/958143/F145109/SyncfusionPatch_17.1.0.38_958143_7042019092631092_F145109.zip

NuGet packages:

http://syncfusion.com/Installs/support/patch/17.1.0.38/958143/F145109/SyncfusionNuget_17.1.0.38_958143_7042019092631092_F145109.zip


After fixing the table preservation issue, we have faced extra paragraph preservation issue. Currently we are working on this with high priority and we will provide you patch for this issue on 12th July, 2019

Assembly Version: 17.1.0.38
Installation Directions :
This patch should replace the files “Syncfusion.DocIO.Base.dll” under the following folder.
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\4.0
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\
17.1.0.38\precompiledassemblies\ 17.1.0.38\4.0

To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.

Note:
To change how you receive bug fixes, ask your license management portal admin to change your project’s patch delivery mode.
https://www.syncfusion.com/account/license

Disclaimer:
Please note that we have created this patch for version
17.1.0.38 specifically to resolve the issue reported in the Forum 145109

If you have received other patches for the same version for other products, please apply all patches in the order received.

This fix will be included in our 2019 Volume 2 Service Pack 1 release which will be available in August, 2019 tentatively.


Please let us know if you have any other questions.

Regards.
Poorani Rajendran

 


Pieter van Kampen
Replied On July 5, 2019 10:30 AM UTC

Thanks for this patch, but unfortunately this only solves part of the problem. I used the Nuget to replace netstandard2.0 assembly in syncfusion.docio.net.core. File version 17.1200.0.715

Attached the output from the sample app (sample.docx) that still has changed the table in bookmark 1 twice, instead of the changing the tables in the two different bookmarks. sample reverse.docx shows the output when the order of replacing is bottom to top, which works. In my real app, there are situations that I can't get to work, also not when working bottom to top. 



Attachment: Sample_5fd0060.zip

Mohanaselvam  Jothi [Syncfusion]
Replied On July 8, 2019 09:58 AM UTC

Hi Pieter,

Thank you for your update.

We have tried to reproduce the reported bookmark content replacement problem in the given sample application (
Updated on 6/7/2019) using the patch (Updated on 7/4/2019), but it works properly at our end. Please find the generated output from the below link:
https://www.syncfusion.com/downloads/support/forum/145109/ze/Output1295876029

We suspect that the reported problem might be due to the patch conflicts at your end. If you are using NuGet packages, w
e suggest you, try the below solution to resolve the reported problem at your side.
 1. Kindly remove the NuGet packages referred in your application.
2.Delete the respective NuGet packages (syncfusion.docio.net.core) in “.nuget” folder which is available in “C:\Users\{XXX}\.nuget\packages” folder location.
3. Then install the NuGet packages again in your application.
4. Clean the solution, rebuild, and run the application.

Regarding In my real app, there are situations that I can't get to work:
We suspect that the mentioned problem might be due to the input Word document and the formats in the file level. So, could you please share us the input Word document which used in your real app along with the complete code snippet. Thereby, we will check on the problem and will provide you the appropriate solution.

Note: If you have any confidential data in your Word document,
you can also mail the files to our Syncfusion support through support@syncfusion.com with Forum Id as subject.We maintain the confidentiality of the information disclosed by our customers to us. Therefore, any documents shared with Syncfusion will only be used to replicate the issue and will not be shared with anyone else.

Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 


Pieter van Kampen
Replied On July 9, 2019 12:43 PM UTC

Thank you, this solved the issue, also in the document I am using in the application! 

Will this patch be included in any of the upcoming beta versions of Volume 2?

Poorani Rajendran [Syncfusion]
Replied On July 10, 2019 07:20 AM UTC

Hi Pieter,

Thank you for your update.

As mentioned in our earlier update (
Updated on 7/4/2019), after fixing the table preservation issue, we have faced extra paragraph preservation issue. Currently we are working on this with high priority and we will provide you patch for this issue on 12th July, 2019

We will include these fixes (exception and preservation issue) in our 2019 Volume 2 Service Pack 1 release which is expected to be rolled out by end of August, 2019
tentatively

Please let us know if you have any other questions.

Regards,
Poorani Rajendran
 


Suganya Rathinam [Syncfusion]
Replied On July 12, 2019 11:06 AM UTC

Hi Pieter,

Thank you for your patience.

We have fixed the mentioned preservation issue when replacing bookmark content in table
and the patch for the fix in the mentioned version 17.1.0.38 can be downloaded from the following link.

Recommended approach - exe will perform automatic configuration
Please find the patch setup from below location:
http://syncfusion.com/Installs/support/patch/17.1.0.38/958143/F145109/SyncfusionPatch_17.1.0.38_958143_7122019055741387_F145109.exe

Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment
Please find the patch assemblies alone from below location:
http://syncfusion.com/Installs/support/patch/17.1.0.38/958143/F145109/SyncfusionPatch_17.1.0.38_958143_7122019055741387_F145109.zip

NuGet packages:
http://syncfusion.com/Installs/support/patch/17.1.0.38/958143/F145109/SyncfusionNuget_17.1.0.38_958143_7122019055741387_F145109.zip

If you are using NuGet Packages, please remove the existing NuGet package under the following folder.
$system drive:\Users\$user\.nuget\packages\
Then, install the above NuGet in your application to ensure the fix at your end.

Note:
To change how you receive bug fixes, ask your license management portal admin to change your project’s patch delivery mode.
https://www.syncfusion.com/account/license

Disclaimer:
Please note that we have created this patch for version
17.1.0.38 specifically to resolve the issue reported in the Forum 145109

If you have received other patches for the same version for other products, please apply all patches in the order received.

This fix will be included in our 2019 Volume 2 Service Pack 1 release which will be available in August, 2019 tentatively.


Please let us know if you have any other questions.


Regards,
Suganya R


Pieter van Kampen
Replied On July 12, 2019 08:05 PM UTC

Unfortunately this reverts back the previous solution. It does solve the paragraph issue, but gives an error on the second statement:

                bookmarkNavigator.MoveToBookmark(bookmarkName);
                bookmarkNavigator.ReplaceBookmarkContent(textBodyPart);


2019-07-12 21:54:58.8107|::1||ERROR|9.7.9.0|23 |Ehm|ZmLab.ZmLabBloodTable|System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)
   at Syncfusion.DocIO.DLS.ParagraphItemCollection.get_Item(Int32 index)
   at Syncfusion.DocIO.DLS.WParagraph.UpdateBookmarkEnd(ParagraphItem item, WParagraph paragraphStart, Boolean isAddItem)
   at Syncfusion.DocIO.DLS.BookmarksNavigator.SetCurrentBookmarkPosition(WParagraph paragraphStart, WParagraph paragraphEnd, WTextBody textBodyStart, WTextBody textBodyEnd, BookmarkStart bkmkStart, BookmarkEnd bkmkEnd, Int32 startParagraphNextIndex, Boolean isFirstItemBkmkEnd, Boolean isInSingleSection, Boolean isReplaceOperation, Int32 bkmkIndex)
   at Syncfusion.DocIO.DLS.BookmarksNavigator.DeleteBookmarkTextBody(Boolean saveFormatting, Boolean isReplaceBkmkContent)
   at Syncfusion.DocIO.DLS.BookmarksNavigator.DeleteBookmarkContent(Boolean saveFormatting, Boolean removeEmptyParagrph, Boolean isReplaceBkmkContent)
   at Syncfusion.DocIO.DLS.BookmarksNavigator.ReplaceBookmarkContent(TextBodyPart bodyPart)
   at DTODAL.TestModules.ZmLab.ZmLabBloodTable(Int32 psnr, String bookmarkName) in C:\DTOWeb\DTOWEB7\src\DTODAL\TestModules\ZmLab.cs:line 352|Index was out of range. Must be non-negative and less than the size of the collection.

This occurs with file version 17.1200.0.747 but not with 17.1200.715

Poorani Rajendran [Syncfusion]
Replied On July 15, 2019 07:30 AM UTC

Hi Pieter,

Thank you for your update.

We have tried to reproduce the reported “Index was out of range exception issue” in the given sample application (Updated on 6/7/2019) using the patch (Updated on 7/12/2019), but it works properly at our end. Please find the generated output from the below link:
https://www.syncfusion.com/downloads/support/forum/145109/ze/Output377398641

Suspected that the reported problem might in two ways at your end:

Suspect 1:
We suspect that the reported problem might be due to the patch conflicts at your end. If you are using NuGet packages, we suggest you, try the below solution to resolve the reported problem at your side.
1. Kindly remove the NuGet packages referred in your application.
2.Delete the respective NuGet packages (syncfusion.docio.net.core) in “.nuget” folder which is available in “C:\Users\{XXX}\.nuget\packages” folder location.
3. Then install the NuGet packages again in your application.
4. Clean the solution, rebuild, and run the application.

Suspect 2:
The reported problem exists due to code snippet used at your end is differed from the code snippet used in below sample application. Kindly share us or modified the code snippet used at your end in below sample application to reproduce the issue at our end
which will helpful to provide you the appropriate solution at the earliest.

Please find the sample application and it can be downloaded from the below link:
https://www.syncfusion.com/downloads/support/forum/145109/ze/Sample_application168207457525120108

Please let us know if you have any other questions.

Regards,
Poorani Rajendran


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon