Background Color of a Cell

How do I change the background color of a cell to solid orange color.

Here is my code. Seems like the code doesn't work.

worksheet.cells(0, 1).Pattern.Solid = BackgroundType.Solid

worksheet.cells(0, 1).BackgroundColor = Color.Orange

Thanks,

Prakash

Dear Prakash,

Orange color is not in the standard Excel palette. Please check

Aspose.Cells API Reference pages.

For you case, please change your code to :

excel.ChangePalette(Color.Orange, 55)

worksheet.cells(0, 1).Pattern.Solid = BackgroundType.Solid

worksheet.cells(0, 1).BackgroundColor = Color.Orange

Laurence,

Not working. The code you have specified is working for "forecolor" only, does not work for "backgroundcolor". I have reviewed the "aspose.cell" documentation but seems to be doesn't work for "solid background color".

Please specify whether the .component supports this feature or not

Thanks,

Prakash

Sorry. The code should be

excel.ChangePalette(Color.Orange, 55)

worksheet.cells(0, 1).Pattern.Solid = BackgroundType.Solid

worksheet.cells(0, 1).ForegroundColor = Color.Orange

Background color only takes effect if the background pattern is not Solid or None.

Laurence,

Thanks. As per my understanding this component does not support "SOLID" background color of any particular cell or row. Am I correct?. Please confirm.

Thanks,

Prakash

Hi Prakash,

In MS Excel, you can set 2 color for a cells: ForegroundColor and BackgroundColor. If you set "Solid" background color, actually you are setting the foreground color. Only when you set the pattern other than solid, the background color will show. That's the routine of MS Excel.

Laurence,

If this is the case how do we fille the cell "B6" color with "yellow" as specified in attached image file.

Thanks

Prakash

worksheet.cells("B6").ForegroundColor = Color.Yellow

worksheet.cells("B6").Pattern.Solid = BackgroundType.Solid

Thanks alot Lauren. It;s working.