Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Oct 09, 2017 8:42 am

Hello,


I would like to insert an object after "tab" but I do not know get index end of tab.

Code: Select all
  foreach (Section section in doc.Sections)
            {
                foreach (Paragraph paragraph in section.Paragraphs)
                {
                    if (paragraph.Text.Contains("[SEARCH]"))
                    {
                        if (!paragraph.GetStyle().DefaultStyleType.ToString().Equals("Toc2"))
                        {                     
                     index = section.Body.ChildObjects.IndexOf(paragraph);
                     tab.Rows[0].Cells[0].Paragraphs[0].Text = "TESTTEST";
                     tab.Rows[3].Cells[1].CellFormat.Borders.Top.Color = Color.FromArgb(212, 24, 10);

                     section.Body.ChildObjects.Insert(index + 1, tab);

                     // GET INDEX END OF TAB HERE
                        }
                    }
                }
            }


thanks in advance for your return.

elysiumsecurity
 
Posts: 14
Joined: Mon Oct 09, 2017 8:15 am

Mon Oct 09, 2017 10:12 am

Hello,

Please refer to the below code snippet to get the index of a table.
Code: Select all
 var tableIndex=section.Body.ChildObjects.IndexOf(tab);



Sincerely,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.Doc