How to fill cells with gradient?

Hi!

Is it possible to fill cells with gradient, with for example with two colors, using aspose.cells?
All examples I have found only shows how to fill backgrounds in charts. I want to do I nice background with gradient for the column headers in the excel sheet.How do I do that?
Is it also possible to do a gradient filling for the data bars in a chartType.Bars?

I also have problems with background colors . This should be a light gray but it will only be white in the excel:

Private Function GetStyleColumnHeaders(ByVal wb As Workbook) As Style
Dim cellStyle As Style = wb.Styles(wb.Styles.Add)
cellStyle.HorizontalAlignment = TextAlignmentType.Center
cellStyle.ForegroundColor = Drawing.Color.FromArgb(&HCC, &HCC, &HCC)
'cellStyle.ForegroundColor = Drawing.Color.LightGray
cellStyle.Pattern = BackgroundType.Solid
Return cellStyle
End Function

If I use the outcommented line (LightGray) I also only get a white background. Anybody knows why?

Thanks!
Regards,
Jens

Hi Jens,

Thanks for considering Aspose.

Is it possible to fill cells with gradient, with for example with two colors, using aspose.cells?
All examples I have found only shows how to fill backgrounds in charts. I want to do I nice background with gradient for the column headers in the excel sheet.How do I do that?

In MS Excel (97-2003), I don't find any way to do it (set gradient fills to cells). If you could find a way, create a sample file in MS Excel(97-2003) with gradient fills in the cells, we will check and support the feature ASAP. And if you are pointing out MS Excel 2007 feature in which we can set gradient fills for the cells. This feature is not supported yet.

Is it also possible to do a gradient filling for the data bars in a chartType.Bars?

Yes, quite possible, check the following sample line of code.

chart.NSeries(0).Area.FillFormat.SetTwoColorGradient(Color.Yellow,Color.White,GradientStyleType.Vertical,2)

I also have problems with background colors . This should be a light gray but it will only be white in the excel:

Well, light gray color is not present on the standard MS color palette (which has 56 default colors indexed 0-55), so you need to add the color to the palette first before setting it to the shading color for the cell(s). I think you may add line of code to your code:

Private Function GetStyleColumnHeaders(ByVal wb As Workbook) As Style
'Add the light gray color at the last index (55) position in the palette.

wb.ChangePalette(Color.LightGray,55);

Dim cellStyle As Style = wb.Styles(wb.Styles.Add)
cellStyle.HorizontalAlignment = TextAlignmentType.Center
'cellStyle.ForegroundColor = Drawing.Color.FromArgb(&HCC, &HCC, &HCC)
cellStyle.ForegroundColor = Drawing.Color.LightGray
cellStyle.Pattern = BackgroundType.Solid
Return cellStyle
End Function

Thank you.

Hi!

Thanks for the reply!

Can't find a way to fill cells with gradient in MS Excel 97-2003.
When will this be added for MS Excel 2007?

Regards, Jens

Hi Jens,

We will look into this feature.If the feature is supported ,we will post a fix soon.

Thanks for you patience.