Replace Table content ...but not all

Hi,
My need is to replace the contents of a table while retaining formatting, but from a row, say R until to the table end . So I tried to cancel the entire rows from the end to the row R +1.

I’m newbie and trying to understand the Aspose.Words object model, …I’ve not found table.addRow but “similar” method InserCell.

Any suggestions on what is the best method to add data ?

// localize table from my position
Node currentrow = builder.CurrentNode.GetAncestor(NodeType.Row);
if (currentrow != null)
{
    Row _currentRow = (Row) currentrow;
    Table _tab = _currentRow.ParentTable;
    int total_rows = _tab.Rows.Count;
    int R = _tab.IndexOf(_currentRow);
    int _cols = _currentRow.Cells.Count;
    // ....Clear content
    for (var nr = _tab.Rows.Count - 1; nr> R; nr--)
    {
        _tab.Rows.RemoveAt(nr);
    }

<< HELP>>> InsertRow and some dummy data
Thanks in advance

Hello
Thanks for your request. By Microsoft Word design rows in a table in a Microsoft Word document are completely independent. It means each row can have any number of cells of any width. So you can try using the following code to insert Row into the table:

builder.StartTable();

// Insert a cell
builder.insertCell();
builder.writeln("This is row 1 cell 1");
// Insert a cell
builder.insertCell();
builder.writeln("This is row 1 cell 2");
builder.endRow();
// Insert a cell
builder.insertCell();
builder.writeln("This is row 2 cell 1");
// Insert a cell
builder.insertCell();
builder.writeln("This is row 2 cell 2");
builder.endRow();
builder.endTable();

In additional, I think the best way to fill the document with data is using Mail Merge feature. Please follow this link to learn more:
https://docs.aspose.com/words/net/types-of-mail-merge-operations/
Or in your case you can try using Mail Merge with regions. Please see the following link:
https://docs.aspose.com/words/java/types-of-mail-merge-operations/
Best regards,

Thanks you Andrey for your quick response!
…I had some doubts in using builder.endTable() without explicitly started corresponding builder.StartTable. …but now I understand that I must pay attention to only EndRow.
Thanks again.

Hello
Thanks for your inquiry. Call EndRow to end a table row. If you call InsertCell immediately after that, then the table continues on a new row.
Use the RowFormat property to specify row formatting.
Please let me know in case of any issues. I will be glad to help you.
Best regards,