Unable to change the text color but background color is changing

Hello

I am not able to change the text color of the row using style.Font.color property .

Style boldStyle = planWorkBook.CreateStyle();
//Code to change the background color
boldStyle.ForegroundColor = System.Drawing.Color.Blue;
boldStyle.Pattern = BackgroundType.Solid;
//code to change the text color
boldStyle.Font.Color = System.Drawing.Color.White;
boldStyle.Font.IsBold = false;
boldStyle.HorizontalAlignment = TextAlignmentType.Left;

Background change code is working however the text change code is not working.
please help.

@RahulC1065,

Thanks for the code segment.

How do you apply style to the cell/row/range, i think you are missing this thing. See the updated code segment (I have added a few lines to your code segment) for your reference:
e.g
Sample code:

 Workbook planWorkBook = new Workbook();
            Style boldStyle = planWorkBook.CreateStyle();
            //Code to change the background color
            boldStyle.ForegroundColor = System.Drawing.Color.Blue;
            boldStyle.Pattern = BackgroundType.Solid;
            //code to change the text color
            boldStyle.Font.Color = System.Drawing.Color.White;
            boldStyle.Font.IsBold = false;
            boldStyle.HorizontalAlignment = TextAlignmentType.Left;

            StyleFlag flag1 = new StyleFlag();
            flag1.CellShading = true;
            flag1.Font = true;
            flag1.HorizontalAlignment = true;

            //Apply the style to the first row of the first sheet.
            Worksheet worksheet = planWorkBook.Worksheets[0];
            worksheet.Cells.ApplyRowStyle(0, boldStyle, flag1);

            //Apply the style to the A9 cell.
            worksheet.Cells["A9"].SetStyle(boldStyle, flag1);

Also, see the document for your further reference:

Thank for quick reply

I have also added the section you mentioned here . in issue i just mentioned core part.
I am using v5.3.2.0

here is complte code

planWorkBook.ChangePalette(System.Drawing.Color.White, 55);

        Style boldStyle = planWorkBook.CreateStyle();
        boldStyle.ForegroundColor = Color.Blue;
        boldStyle.Pattern = BackgroundType.Solid;

        boldStyle.Font.Color = Color.White;
        boldStyle.Font.IsItalic = true;
        boldStyle.Font.IsBold = true;
        
        boldStyle.HorizontalAlignment = TextAlignmentType.Left;
        StyleFlag boldStyleFlag = new StyleFlag();
        boldStyleFlag.HorizontalAlignment = true;
        boldStyleFlag.FontBold = false;
        boldStyleFlag.CellShading = true;
        Row row1 = planWorkBook.Worksheets[0].Cells.Rows[0];
        row1.Height = 40;
        row1.ApplyStyle(boldStyle, boldStyleFlag);

please suggest

@RahulC1065,

I used the following sample code with our latest version/fix: Aspose.Cells for .NET v18.5.x, it works fine:
e.g
Sample code:

Workbook planWorkBook = new Workbook();
            Style boldStyle = planWorkBook.CreateStyle();
            //Code to change the background color
            boldStyle.ForegroundColor = System.Drawing.Color.Blue;
            boldStyle.Pattern = BackgroundType.Solid;
            //code to change the text color
            boldStyle.Font.Color = System.Drawing.Color.White;
            boldStyle.Font.IsBold = false;
            boldStyle.HorizontalAlignment = TextAlignmentType.Left;

            StyleFlag flag1 = new StyleFlag();
            flag1.CellShading = true;
            flag1.Font = true;
            flag1.HorizontalAlignment = true;

            
            Worksheet worksheet = planWorkBook.Worksheets[0];
            worksheet.Cells["A1"].PutValue("testin...");
            worksheet.Cells["A9"].PutValue("hello");

            //Apply the style to the first row of the first sheet.
            worksheet.Cells.ApplyRowStyle(0, boldStyle, flag1);

            //Apply the style to the A9 cell.
            worksheet.Cells["A9"].SetStyle(boldStyle, flag1);

            planWorkBook.Save("e:\\test2\\out1.xlsx"); 

I have also attached the output file for your reference.

Since you are using some older version of the product, so we are not sure if it was working or not. But it works absolutely fine using latest version/fix. Moreover, we neither can evaluate your issue in older version nor we can fix any issue (if found). The fixes are based on latest APIs set.
files1.zip (6.3 KB)