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

Free Support Forum - aspose.com

Bad color

Hi,

I try to set font color for part of string using

cell.Characters(0,7).Font.Color = Color.FromArgb(0, 153, 204);

but in sheet is color 0, 102, 204 it seem as bug.


when i set color using

Style style = cell.GetStyle();
style.Font.Color = Color.FromArgb(0, 153, 204);

in sheet is correctly 0,153,204

Hi,

Thanks for your simple sample code and using Aspose.Cells.

Please download and use the latest version: Aspose.Cells for .NET 8.6.1, it works fine.

I have tested this issue with the following sample code and it showed the correct color in output excel file. I have attached the source excel file used in this code and output excel file generated by it for your reference.

C#
Workbook workbook = new Workbook(“source.xlsx”);

Worksheet worksheet = workbook.Worksheets[0];

Cell cell = worksheet.Cells[“A1”];

cell.Characters(0, 7).Font.Color = Color.FromArgb(0, 153, 204);

workbook.Save(“output.xlsx”);

thank for replay

this bug is only for SaveFormat.Excel97To2003

Hi,


Please see the document for your reference:
http://www.aspose.com/docs/display/cellsnet/Colors+and+Palette

Well, you may add / update your custom RGB color to the MS Excel (2003) color palette before applying color to your desired characters in the cell. For your information, for XLS (Excel 2003), there is a limitation and only 56 colors are there in the standard color palette, there is no such limitation for XLSX (Excel 2007/2010 and 2013 file format(s)) though. You may change the color palette for adding color by using Workbook.ChangePalette() method.

Please see sample code below that works fine:
e.g
Sample code:

Workbook workbook = new Workbook(“e:\test2\source.xlsx”);
workbook.ChangePalette(Color.FromArgb(0, 153, 204), 55);

Worksheet worksheet = workbook.Worksheets[0];

Cell cell = worksheet.Cells[“A1”];

cell.Characters(0, 7).Font.Color = Color.FromArgb(0, 153, 204);

workbook.Save(“e:\test2\output1.xls”);


Hope, this helps a bit.

Thank you.