Hi @acturisaspose
I appreciate your interest in Aspose products.
I prepared some simple code that will help you achieve what you need.
private void Logic(Document doc)
{
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
builder.InsertCell();
builder.Writeln("Item");
builder.InsertCell();
builder.Writeln("Quantity (kg)");
builder.EndRow();
builder.InsertCell();
builder.Writeln("Apples");
builder.InsertCell();
builder.Writeln("20");
builder.EndRow();
builder.InsertCell();
builder.Writeln("Bananas");
builder.InsertCell();
builder.Writeln("40");
builder.EndRow();
builder.InsertCell();
builder.Writeln("Carrots");
builder.InsertCell();
builder.Writeln("50");
builder.EndRow();
table.AutoFit(AutoFitBehavior.AutoFitToContents);
var rowList = table.Rows.Cast<Row>().ToList();
bool odd = true;
foreach (var row in rowList)
{
odd = !odd;
foreach (Cell cell in row.ChildNodes)
{
if (odd)
{
cell.CellFormat.Shading.BackgroundPatternColor = Color.Aqua;
cell.CellFormat.Shading.Texture = TextureIndex.TextureSolid;
cell.CellFormat.Borders.LineStyle = LineStyle.DotDash;
}
else
{
cell.CellFormat.Shading.BackgroundPatternColor = Color.Magenta;
cell.CellFormat.Borders.LineStyle = LineStyle.DoubleWave;
}
foreach (Run run in cell.GetChildNodes(NodeType.Run, true))
{
Aspose.Words.Font font = run.Font;
if (odd)
{
// Set some font formatting properties
font.Bold = true;
font.Color = System.Drawing.Color.Red;
font.Name = "Verdana";
}
else
{
font.Bold = false;
font.Color = System.Drawing.Color.Blue;
font.Name = "Calibri";
}
}
}
}
}
I exaggerated the styles just for the sake of viewing them. I attached the result of running the code sample.
TableStylesPerRow_output.docx (7.3 KB)
Please let me know if you would like to know something else.
Best regards.