We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting a Table Cell Background Color

Is it possible to set the background color in a table cell or row. I have tried this - but it does not shade the cells with the background:

tf = table.GetCell(i, 1).TextFrame;

tf.Paragraphs[0].Alignment = TextAlignment.Center;

tf.Paragraphs[0].Portions[0].RawFontBold = true;

tf.Paragraphs[0].Portions[0].RawFontHeight = 8;

tf.FillFormat.BackColor = Color.Blue;

tf.Paragraphs[0].Portions[0].FontColor = Color.White;


This message was posted using Page2Forum from Creating a Table from Scratch - Aspose.Slides for .NET

Hi Cliff,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your interest in Aspose.Slides.

Please use the code snippet below to set the color of table cell. Also find the attached sample presentation.

Presentation pres = new Presentation("d://ppt//asd.ppt");

Slide slide = pres.Slides[0];

int xPosition = 880;

int yPosition = 1400;

int tableWidth = 4000;

int tableHeight = 500;

int columns = 4;

int rows = 4;

double borderWidth = 2;

//Adding a new table to the slide using specified table parameters

Table table = slide.Shapes.AddTable(xPosition, yPosition, tableWidth, tableHeight,

columns, rows, borderWidth, Color.Blue);

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

{

table.GetCell(i, 0).FillFormat.Type = FillType.Solid;

table.GetCell(i, 0).FillFormat.ForeColor = Color.Brown;

TextFrame tf = table.GetCell(i, 1).TextFrame;

tf.Paragraphs[0].Alignment = TextAlignment.Center;

tf.Paragraphs[0].Portions[0].FontBold = true;

tf.Paragraphs[0].Portions[0].RawFontHeight = 8;

tf.FillFormat.BackColor = Color.Blue;

tf.Paragraphs[0].Portions[0].FontColor = Color.White;

}

pres.Write("c://aas.ppt");

Thanks and Regards,