I can’t seem to find the code to set the color for a selected cell in a table using c# .net. I’ve created an example template that I open, it has a table in one of the slides which I can access and update. However I can’t seem to find the correct command to set an RGB color for a given cell. I’ve tried the following:
using Aspose.Slides;
//opening the presentation
string presLocation = “test presentation.pptx”;
Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation(presLocation);
//selecting the slide
sld = pres.Slides[2];
//selecting the table
Aspose.Slides.Table table = (Aspose.Slides.Table)sld.FindShapeByAltText(“table”);
//updating text for col 0, row 1 particular cell in the table
table[0, 1].TextFrame.Text = “updated 1”;
//changing the text color for a col 1 row 1 cell to red
Portion portion = (Portion)table[1, 1].TextFrame.Paragraphs[0].Portions[0];
portion.PortionFormat.FillFormat.FillType = FillType.Solid;
portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;
//attempting to set col 4 row 1 to red
table[4, 1].FillFormat.FillType = FillType.Solid;
table[4, 1].FillFormat.SolidFillColor.ColorType = ColorType.RGB;
table[4, 1].FillFormat.SolidFillColor.Color = Color.FromArgb(250,0,0);
//save presentation
pres.Save(“test presentation aspose.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);
I’ve looked through the forum and with some of the other languages there seems to be methods that I don’t have access to in C# (for example to set the ForColor). Perhaps I need to add some further refrences, etc… or I’m looking in the wrong place. Thanks for your help.