Hi
Please suggest how to set text color of All Characters in a Row .
Sunil
Hi
Please suggest how to set text color of All Characters in a Row .
Sunil
Hi,
Thank you for considering Aspose.
You can use Style.Font.Color to Specify the Row Characters color. Please see the following Sample code which will help you to get your desired results.
Sample Code:-
Workbook workbook = new Workbook();
workbook.Open("f:\\Excels\\Input.xls");
//Add Sheet Style
Aspose.Cells.Style stl2 = workbook.Styles[workbook.Styles.Add()];
//Set Font Color
stl2.Font.Color = System.Drawing.Color.Blue;
//Set the style flag struct.
StyleFlag flag = new StyleFlag();
flag.FontColor = true;
//Get the first Row in the first worksheet.
Aspose.Cells.Row Row1 = workbook.Worksheets[0].Cells.Rows[0];
//Apply the style to it.
Row1.ApplyStyle(stl2, flag);
//Save the Workbook
workbook.Save("F:\\Excels\\Output.xls");
Thank You & Best Regards,
Thanks for your Reply.
I have made all changes as suggested, Now Aspose.Cell is changing Text color of All rows , i want change of single row colors.
- backgroup color of Row is Blue
- Text color of Each Column should be White.
Please suggest.
Sunil
Hi Sunil,
Thank you for considering Aspose.
Well, I am not sure what you mean by “Now Aspose.Cell is changing Text color of All rows”, because above mentioned code just changes the Font Color in Row 1 of the worksheet. As per your detail, what I understood is that you want the Row Background color to be Blue and The Text Color in that Row to be White. To Get this you may use the under-mentioned sample code.
Sample Code:-
Workbook workbook = new Workbook();
workbook.Open("f:\\Excels\\Input.xls");
//Add Sheet Style
Aspose.Cells.Style stl2 = workbook.Styles[workbook.Styles.Add()];
//Set Font Color
stl2.Font.Color = System.Drawing.Color.White;
//Set Background Color
stl2.ForegroundColor = System.Drawing.Color.Blue;
//Set Background Color Pattern
stl2.Pattern = BackgroundType.Solid;
//Set the style flag struct.
StyleFlag flag = new StyleFlag();
flag.FontColor = true;
flag.CellShading = true;
//Get the first Row in the first worksheet.
Aspose.Cells.Row Row1 = workbook.Worksheets[0].Cells.Rows[0];
//Apply the style to it.
Row1.ApplyStyle(stl2, flag);
//Save the Workbook
workbook.Save("F:\\Excels\\Output.xls");
If this is not what you are requiring, please make a sample Excel file in MS Excel which explains your requirement so that a solution can be provided to you as per your requirement.
Thank you & Best Regards,