This project has moved and is read-only. For the latest updates, please go here.

Gradient in version 3.0

May 4, 2012 at 5:57 AM

The readme for the version 3.0 I just downloaded says gradients were added. I would appreciate some help in using them.

May 15, 2012 at 8:21 PM

Hi,

Heres a samples from the test project...

var ws = _pck.Workbook.Worksheets.Add("Fills");

ws.Cells["A1:C3"].Style.Fill.Gradient.Type = ExcelFillGradientType.Linear;
ws.Cells["A1:C3"].Style.Fill.Gradient.Color1.SetColor(Color.Red);
ws.Cells["A1:C3"].Style.Fill.Gradient.Color2.SetColor(Color.Blue);

ws.Cells["A1"].Style.Fill.PatternType = ExcelFillStyle.MediumGray;
ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(Color.ForestGreen);
var r=ws.Cells["A2:A3"];
r.Style.Fill.Gradient.Type = ExcelFillGradientType.Path;
r.Style.Fill.Gradient.Left = 0.7;
r.Style.Fill.Gradient.Right = 0.7;
r.Style.Fill.Gradient.Top = 0.7;
r.Style.Fill.Gradient.Bottom = 0.7;
            
ws.Cells[4,1,4,360].Style.Fill.Gradient.Type = ExcelFillGradientType.Path;

for (double col = 1; col < 360; col++)
{                
    r = ws.Cells[4, Convert.ToInt32(col)];
    r.Style.Fill.Gradient.Degree = col;
    r.Style.Fill.Gradient.Left = col / 360;
    r.Style.Fill.Gradient.Right = col / 360;
    r.Style.Fill.Gradient.Top = col / 360;
    r.Style.Fill.Gradient.Bottom = col / 360;
}
r = ws.Cells["A5"];
r.Style.Fill.Gradient.Left = .50;
Jan