How to move the cursor to the table's cell and insert text using .NET

Hi,

this is my code:

wordlic.SetLicense(“Aspose.Total.lic”);

        Document docIndex = new Document("example.docx");
        DocumentBuilder builder = new DocumentBuilder(docIndex);
        builder.MoveToSection(1);
        builder.MoveToCell(4, 0, 0, 0);

here is my document: example.zip (90.8 KB)

When I try to move the cell of the fifth table, I get this exception:
Exception thrown: ‘System.ArgumentOutOfRangeException’ in Aspose.Words.dll
Additional information: Specified argument was out of the range of valid values. occurred

As you can see, this document has 5 tables and two sections.

Can you help me ?

Kind regards,
Guido

@Nachti

The DocumentBuilder.MoveToSection method moves the cursor to the beginning of the body in a specified section. Please use the following code example to get the desired output.

Document docIndex = new Document(MyDir + "example.docx");
DocumentBuilder builder = new DocumentBuilder(docIndex);
Console.WriteLine(docIndex.Sections[1].Body.Tables.Count);
builder.MoveToSection(1);
builder.MoveToCell(0, 0, 0, 0);
builder.Write("aspose.words");

docIndex.Save(MyDir + "output.docx");