Fill table in word

hello, I have a document with a table that has already been created in MSOfficeWord, how i filling their cells with Aspose. and how insert new rows in the this table?

Thank you.

Greetings!


Hi there,


Thanks for your inquiry.
eldioni09:

how i filling their cells with Aspose

You can use DocumentBuidler.MoveToCell method to move cursor to the beginning of the cell and write the text. Please check following code example for your kind reference.


// Open document and create
DocumentBuidler.

Document doc = new Document(@"Test001\in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

// move builder cursor to the beggining of the first cell of the first table.

builder.MoveToCell(0, 0, 0, 0);

// Insert some text.

builder.Write("This is text at the begginng of the cell");

// Save output document.

doc.Save(@“Test001\out.doc”);

eldioni09:

and how insert new rows in the this table?

Please use the following code example to
insert row at the end of table. Hope this helps you.

Document doc = new
Document(@“Test001\in.doc”);

// Retrieve the first table in the document.

Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

// Clone the last row in the table.

Row clonedRow = (Row)table.LastRow.Clone(true);

// Remove all content from the cloned row's cells. This makes the row ready for

// new content to be inserted into.

foreach (Cell cell in clonedRow.Cells)

{

cell.RemoveAllChildren();

// Add a blank paragraph to the cell.

cell.AppendChild(new Paragraph(doc));

// Add the text.

cell.FirstParagraph.AppendChild(new Run(doc, "cellText"));

}

// Add the row to the end of the table.

table.AppendChild(clonedRow);

doc.Save(@“Test001\out.doc”);