How to change background color of table row using Aspose.Slides?

I’m using Aspose.slides .NET and try to change the row background color in a table. Based on the samples, I should be able to set it with CellFormat.FillFormat.PatternFormat.ForeColor.Color. However, it just doesn’t change the default color no matter whether I tried with CellFormat or PortionFormat.

public static ITable AddTable(ISlide slide, float x, float y, double[] dblCols, double[] dblRows)
{
ITable table = slide.Shapes.AddTable(x, y, dblCols, dblRows);
table.FirstRow = true;
table.HorizontalBanding = false;
Color tableHeaderFillColor = Color.FromArgb(48, 158, 199); // Hex #309EC7

        // setting first row cells' font height
        PortionFormat portionFormat = new PortionFormat();
        portionFormat.FontHeight = 14;
        portionFormat.FillFormat.FillType = FillType.Solid;
        portionFormat.FillFormat.SolidFillColor.Color = Color.White;

        **portionFormat.FillFormat.PatternFormat.ForeColor.Color = tableHeaderFillColor;** 
        table.Rows[0].SetTextFormat(portionFormat)
        
        for (int n = 0; n < dblCols.Length; n++)
        {
            table[n, 0].TextAnchorType = TextAnchorType.Center;
        }
        // setting the rest row cells text color
        portionFormat.FillFormat.SolidFillColor.Color = Color.Red;
        background = table[1, 1].CellFormat.FillFormat.PatternFormat;
        for (int i = 1; i < dblRows.Length; i++)
        {
            table.Rows[i].SetTextFormat(portionFormat);
            for (int n = 0; n < dblCols.Length; n++)
            {
                //set text vertical alignment
                table[n, i].TextAnchorType = TextAnchorType.Center;

                //set border
                table[n, i].CellFormat.BorderTop.FillFormat.FillType = FillType.NoFill;
                table[n, i].CellFormat.BorderLeft.FillFormat.FillType = FillType.NoFill;
                table[n, i].CellFormat.BorderBottom.FillFormat.FillType = FillType.Solid;
                table[n, i].CellFormat.BorderBottom.FillFormat.SolidFillColor.Color = tableHeaderFillColor;

                //set cell background color
                **table[n, i].CellFormat.FillFormat.PatternFormat.ForeColor.Color = Color.White;**
            }
        }

        return table;
    }

@schangjie,
Thank you for posting the query. It will take me a while to investigate the issue. I will answer you as soon as possible.

@schangjie,
You can change the background color of table cells as shown below:

// set cell background color
table[n, i].CellFormat.FillFormat.FillType = FillType.Solid;
table[n, i].CellFormat.FillFormat.SolidFillColor.Color = Color.White;

More examples: Manage Table, Manage Cells
API Reference: ICellFormat Interface, IFillFormat Interface

Also, I did not find the capability to change the background color of a whole table row at once. Would you like us to add such a feature to Aspose.Slides?

@Andrey_Potapov
Great, above works! Yes. I think it would be very useful to add feature to change the background color of a whole table row. Also I think it would be very useful to add above to the doc samples.

@schangjie,
We will improve the documentation as soon as possible. I added a ticket with ID SLIDESNET-42754 (changing the background color of a whole table row at once) in our tracking system for you. Our development team will consider implementing this feature. You will be notified when it is implemented.