Fill table and add rows

Hello
I have a document with a table with 2 columns and 1 row.
I have a bookmark i the first cell. There is no text in the table.
I would like to add, lets say 4 rows af data to the table starting in the first (existing) row.
How do I add three rows to the table and fill the cells with data ?
(I keep getting nullpointerexception errors)
Best regards
Ole Kirkholt

Hi
Thanks for your request. I think that you can use DocumentBuilder class to achieve this. You should move to the cell, and then get current row and current table. Add some rows to table and fill cells. For example see the following code.

Document doc = new Document(@"337_101645_kirkholt\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("test");
// get current cell
Cell parentCell = builder.CurrentParagraph.ParentNode as Cell;
// get current row
Row parentRow = parentCell.ParentRow;
// get current table
Table parentTable = parentRow.ParentTable;
// add 10 rows to table
for (int i = 0; i < 10; i++)
{
    parentTable.Rows.Add(parentRow.Clone(true));
}
// fill cels 
for (int i = 0; i < parentTable.Rows.Count; i++)
{
    for (int j = 0; j < parentTable.Rows[i].Cells.Count; j++)
    {
        builder.MoveToCell(0, i, j, 0);
        builder.Write(String.Format("Row index = {0}; Cell index = {1}", i.ToString(), j.ToString()));
    }
}
// save document
doc.Save(@"337_101645_kirkholt\out.doc");

I hope that this will help you.
Best regards.