Free Support Forum -

Dynamic table alternating row colors

Hey guys,

Is it possible to make dynamic tables have alternating row colors, much like .Net’s datagrid control?

Here’s an example:

I am currently using Aspose.Words v1.1.4322



Thanks for your inquiry. I think that you can try to change background color. See the following code example.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//generate table

for (int i = 0; i < 10; i++)


for (int j = 0; j < 5; j++)


builder.CellFormat.Width = 100;


//change background

if (i % 2 != 0)


builder.CellFormat.Shading.BackgroundPatternColor = Color.Gray;




builder.CellFormat.Shading.BackgroundPatternColor = Color.White;







I hope that this will help you.

Also, I would advise to use the latest version of Aspose.Words.

The latest version of Aspose.Words is available for download from here.

Best regards.

Ahh okay. I coded something like that yesterday, but was wondering if there was a simple property to set like the .net datagrid. This works though.

Thanks, Alexey.