We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Fill table fields with string data


For the attached sample document, can you share sample code how to fill each field in each table of the document?MEC.zip (10.2 KB)


Thanks for your inquiry. In your case, we suggest you please use Linq Reporting to achieve your requirement. Please refer to the following articles.
Introduction to LINQ Reporting Engine
Template Syntax
Typical Templates

Thanks tahir,

but that seems very complex approach. Is there something where I can just traverse through each cell of a table and set its value manually? Our requirement is not that complete and data is input from user via Windows form input fields based on what this document is to be generated. I am sure there must be some way to achieve it without getting into this Linq Reporting or anything else complex. Please advice ASAP.


Thanks for your inquiry. Yes, you can achieve your requirement without using LINQ Reporting. Please refer to the following article.
Using DocumentBuilder to Modify a Document Easily
Use DocumentBuilder to Insert Document Elements

In your case, we suggest you please use DocumentBuilder.MoveToCell method to move the cursor to a table cell in the current section and insert the content using DocumentBuilder.Write method.

You may also use DocumentBuilder.MoveTo method to move the cursor to the first paragraph node of table’s cell and insert the content. Following code example shows how to move the cursor to table’s cell and insert the content.Hope this helps you.

Document doc = new Document(MyDir + "MEC.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
    if (table.FirstRow.FirstCell.ToString(SaveFormat.Text).Contains("Caller Details"))
        foreach (Row row in table.Rows)
            if (row.FirstCell.ToString(SaveFormat.Text).Trim().Equals("Name:"))
                builder.Write("Jhon Smith");
doc.Save(MyDir + "output.docx");