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

Free Support Forum - aspose.com

How to change color in text of table cell (C#)

I’m trying to add font/text color in the text of the table cell but it’s not working, it’s working fine for background color.

I have tried with v14 to the latest (v19.11) version of Aspose Slide .Net, but remain the same for all.

here is some sample portion of my code.

 public static void TestTableIssue()
    {
        Presentation pres = new Presentation();
        ISlide sld = pres.Slides[0];

        ITable tbl = sld.Shapes.AddTable(100, 50, new double[] { 500 }, new double[] { 20 });
        var portion = tbl[0, 0].TextFrame.Paragraphs[0].Portions[0];
        portion.Text = "This is a demo text";
        portion.PortionFormat.FillFormat.FillType = FillType.Solid;
        portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;

        tbl[0, 0].FillFormat.FillType = FillType.Solid;
        tbl[0, 0].FillFormat.SolidFillColor.Color = Color.Green;

        pres.Save("D:/Temp/" + DateTime.Now.Ticks.ToString() + ".pptx", SaveFormat.Pptx);
    }
1 Like

@VLonetech,

I have observed your sample code. You are using obsolete properties in your code. Please try using following sample code.

    public static void TestTableIssue()
    {
        Presentation pres = new Presentation();
        ISlide sld = pres.Slides[0];

        ITable tbl = sld.Shapes.AddTable(100, 50, new double[] { 500 }, new double[] { 20 });
        var portion = tbl[0, 0].TextFrame.Paragraphs[0].Portions[0];
        portion.Text = "This is a demo text";
        portion.PortionFormat.FillFormat.FillType = FillType.Solid;
        portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;

        tbl[0, 0].CellFormat.FillFormat.FillType = FillType.Solid;
        tbl[0, 0].CellFormat.FillFormat.SolidFillColor.Color = Color.Green;
        String path = @"//Users//mudassir//Downloads//";

        pres.Save( path+ DateTime.Now.Ticks.ToString() + ".pptx", SaveFormat.Pptx);
    }

Hello @mudassir.fayyaz,

The issue is with the font color of the text of the table cell. From your code, I see it’s the same for the font color of the text, no change in the text color.

please have a look once again.

@VLonetech,

The above sample code that I have shared produced the correct output on my end using Aspose.Slides for .NET.

637124605162851710.pptx.zip (22.7 KB)

Thanks @mudassir.fayyaz,

Actually, I am using “Open Office” tool instead of MS office. And Open office causes issue. :frowning:

Its working fine in the MS office. Thanks for your support.

VLonetech,

Thank you for your feedback.