Filling gradient

Hi,

So I am using aspose to format cells in my excel. I want to fill a range with gradient colors. Here is the code:

styleBoldGreyed.ForegroundColor = System.Drawing.ColorTranslator.FromOle(16777215)
styleBoldGreyed.SetTwoColorGradient(Drawing.Color.White, System.Drawing.ColorTranslator.FromOle(16777215), GradientStyleType.Horizontal, 1)

I am not sure what else I need to do because the resulting excel does not have any gradients.

In excel, it is easy to add a gradient. Just right-click on a cell -> Format Cells -> Fill -> Fill Effect.

And there are no samples to do this … the only samples are there for charts…

I would appreciate help on this…

PS: The colour has already been added to the palette.

Hi,

Well, I think you cannot set Ole colors for the cells. It looks that you might be using Aspose.Cells in vb script or something else. You should use System.Drawing.Color.FromArgb() instead of System.Drawing.ColorTranslator.FromOle(). Moreover, you should create a .NET wrapper class that can access Aspose.Cells APIs for your tasks. You will access that wrapper class in your vbscript/javascript or else.

Here is my sample VB.NET code that works fine.

Sample code:

Dim workbook As New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
Dim cells As Cells = sheet.Cells
Dim cell As Aspose.Cells.Cell = cells(“A1”)
cell.PutValue(“Test”)
cell.Style.SetTwoColorGradient(System.Drawing.Color.White, System.Drawing.Color.FromArgb(123,234,10), GradientStyleType.Horizontal, 1)

workbook.Save(“f:\test\out_Gradientcellcolor.xlsx”, FileFormatType.Excel2007Xlsx)


Thank you.

No this does not work.

I am currently getting this the plain background.



what i need is the gradient background…


Hi,

Could you post a sample project here to show the issue? We will check it soon.

Thank you.