Hi,
I’m converting project from Word Automation to Aspose.Word. In the project, MoveRight(Cell) and TypeText are heavily used to move around the table to insert data.
For example:
Name |
Quantity |
Unit Price |
Total |
(+Item+) |
|
|
|
I will find the tag (+Item+) and replace with the item name. Then i will move to next cell to insert quantity, unit price, total accordingly. If i have another item, i will using the command “MoveRight(Cell)” and it will automatically create a new row appending to that table.
How can i achieve this using Aspose.Word. Any advice is appreciated.
Hi Yew,
Thanks for your inquiry.
You can use DocumentBuilder.MoveToCell method if you need to move the cursor to a table cell in the current section. After moving the cursor to specified Cell, you can insert Document elements there. You can also get a reference to current Cell by using DocumentBuilder.CurrentNode,** iterate through all Cells in current Row and change their DOM properties using the following code:
// Iterate through all cells in the row
foreach(Cell cell in row.Cells)
{
int cellIndex = row.Cells.IndexOf(cell);
// Get the plain text content of this cell.
string cellText = cell.ToString(SaveFormat.Text).Trim();
// Print the content of the cell.
Console.WriteLine("\t\tContents of Cell:{0} = \"{1}\"", cellIndex, cellText);
}
I hope, this helps.
Best regards,