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

Free Support Forum - aspose.com

Setting GridDesktop.Style color not working

I am having trouble with setting the Color setting an a GridDesktop Style object. I am running code below but when debugging on the 4th line the Color property of the Style object is showing as empty, even though i set it to red in the line above.

I’m using version 19.2

Thanks, Zoe

Aspose.Cells.GridDesktop.GridCell cell = myWorksheet.Cells[“A1”];
Aspose.Cells.GridDesktop.Style style = cell.GetStyle();
style.Color = Color.Red;


Thanks for providing us some details.

Please try using ForegroundColor attribute with solid pattern type. See the updated code segment for your reference:
Sample code:

Aspose.Cells.GridDesktop.Worksheet myWorksheet = gridDesktop1.Worksheets[0];
            Aspose.Cells.GridDesktop.GridCell cell = myWorksheet.Cells["A1"];
            Aspose.Cells.GridDesktop.Style style = cell.GetStyle();
            style.ForegroundColor = Color.Red;
            style.Pattern = GridBackgroundType.Solid;

Hope, this helps a bit.

1 Like

Thank you for the quick reply. That works perfectly.
Thanks, Zoe


Good to know that your issue is sorted out by the suggested code. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.