I have a docx with a table in it. The table contain only header row and 1 empty row. I have already set formatting for the table to use specific font-size/font-name...
When inserting data to the table, all the new row/cell inserted are not using the formatting of the previous row/cell but fallback to the default font (Calibri)
The code to insert new row and append text for the cell that I'm using is very simple as below:
for (var rIdx = 1; rIdx <= data.Rows.Count; rIdx++)
{
var dataRow = data.Rows[rIdx -1];
var prevTableRow = table.Rows[rIdx - 1];
if (rIdx >= table.RowCount)
{
table.InsertRow(prevTableRow, true);
}
var docRow = table.Rows[rIdx];
docRow.Cells[0].Paragraphs[0].RemoveText(0);
docRow.Cells[0].Paragraphs[0].Append(rIdx.ToString());
for (int cIdx = 0; cIdx < dataRow.Columns.Count; cIdx++)
{
var dataCell = dataRow.Columns[cIdx];
docRow.Cells[cIdx + 1].Paragraphs[0].RemoveText(0);
docRow.Cells[cIdx + 1].Paragraphs[0].Append(dataCell.Value);
}
}
You can see the problem as in the attached file.