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
close icon

itemEndIndex Exception at DocIO

Hi Syncfusion,

I was getting the Exception error.

Exception Details: System.ArgumentOutOfRangeException: m_itemEndIndex is less than 0 or greater than 6
Parameter name: m_itemEndIndex.

I was trying to create multiple table and replace it but it was not working.

Please check and let me know where I was doing and make 1 working example of that



Attachment: DocTest_3797a9dc.zip


1 Reply

AA Akash Arul Syncfusion Team November 16, 2022 03:56 PM UTC

From the given code snippet, we have found that you are created temporary Word document instance and added one section and table into it. Then tried to copy that table to the text body part using text body selection. TextBodySelection API should select the contents between the paragraphs. But only table is present and no paragraphs in that text body. So, it causes the reported exception issue in TextBodySelection API. If text body contains only table, TextBodySelection API is not suitable for your requirement.


From the given details, we understood that your requirement is to replace the text with a table in the Word document.

To achieve your requirement, we suggest you to add the table in the text body part directly without using text body selection and then replace the text with that text body part using Replace API.

Refer our UG documentation to know how to find and replace text with a table in the Word document,
https://help.syncfusion.com/file-formats/docio/working-with-find-and-replace#find-and-replace-text-with-a-table

We have modified your code snippet and prepared a sample application to achieve your requirement and it can be downloaded from the below attachment.

Note: Please find the input Word document in the “Data” folder of the attached sample application.

Refer our UG documentation link to know more about find and replace functionality,
https://help.syncfusion.com/file-formats/docio/working-with-find-and-replace


Attachment: DocIOCore_95494b8.zip

Loader.
Live Chat Icon For mobile
Up arrow icon