Class GradientFill
Contents
[
Hide
]GradientFill class
Represents the gradient fill.
public class GradientFill : Fill
Properties
Name | Description |
---|---|
Angle { get; set; } | The angle of linear fill. |
DirectionType { get; } | Gets the gradient direction type. |
FillType { get; } | Gets the gradient fill type. |
GradientStops { get; } | Represents the gradient stop collection. |
Methods
Name | Description |
---|---|
override Equals(object) | /(Inherited from Fill .) |
override GetHashCode() | Gets the hash code.(Inherited from Fill .) |
SetGradient(GradientFillType, double, GradientDirectionType) | Set the gradient fill type and direction. |
SetOneColorGradient(Color, double, GradientStyleType, int) | Sets the specified fill to a one-color gradient. Only applies for Excel 2007. |
SetPresetThemeGradient(PresetThemeGradientType, ThemeColorType) | Sets preset theme gradient fill. |
SetTwoColorGradient(Color, Color, GradientStyleType, int) | Sets the specified fill to a two-color gradient. Only applies for Excel 2007. |
SetTwoColorGradient(Color, double, Color, double, GradientStyleType, int) | Sets the specified fill to a two-color gradient. Only applies for Excel 2007. |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Drawing;
using System.Drawing;
public class DrawingClassGradientFillDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add a rectangle shape to the worksheet with all required parameters
Shape shape = worksheet.Shapes.AddRectangle(5, 5, 0, 0, 150, 100);
// Set fill type to gradient to access gradient fill properties
shape.Fill.FillType = FillType.Gradient;
// Get the existing gradient fill instance from the shape
GradientFill gradientFill = shape.Fill.GradientFill;
// Configure the gradient with two colors using the existing instance
gradientFill.SetTwoColorGradient(
Color.LightSkyBlue, // First color
Color.DarkBlue, // Second color
GradientStyleType.Horizontal, // Gradient style
1 // Variant
);
// Save the workbook
workbook.Save("GradientFillDemo.xlsx");
}
}
}
See Also
- class Fill
- namespace Aspose.Cells.Drawing
- assembly Aspose.Cells