When we add a row to a table, the cells default to Normal style.
Is there a way to specify an alternative style to be used on rows and cells added to the table?
// Load Word document from disk
Document document = new Document();
document.LoadFromFile(@"..\..\data\input.docx");
//Get the first section
Section section = document.Sections[0];
//Get tables
Table tb1 = section.Tables[0] as Table;
//Set style for row2
TableRow row2 = tb1.Rows[1];
//Set back color for row2
row2.RowFormat.BackColor = Color.LightGray;
row2.RowFormat.CellSpacing = 2;
row2.HeightType = TableRowHeightType.Exactly;
row2.Height = 20f;
//Set style for row3
TableRow row3 = tb1.Rows[2];
//Set back color for cell1 in row3
row3.Cells[0].CellFormat.BackColor = Color.Red;
//Set width and color for border of cell2
row3.Cells[1].CellFormat.Borders.BorderType = BorderStyle.Single;
row3.Cells[1].CellFormat.Borders.LineWidth = 1f;
row3.Cells[1].CellFormat.Borders.Left.Color = Color.Red;
row3.Cells[1].CellFormat.Borders.Right.Color = Color.Red;
row3.Cells[1].CellFormat.Borders.Top.Color = Color.Red;
row3.Cells[1].CellFormat.Borders.Bottom.Color = Color.Red;
//Save the result word file
document.SaveToFile(@"../../output/output.docx",FileFormat.Docx);