Class FillFormat
Namespace: Aspose.Cells.Drawing
Assembly: Aspose.Cells.dll (25.2.0)
Encapsulates the object that represents fill formatting for a shape.
public class FillFormat
Inheritance
Derived
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
csharp
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "A4" cell
worksheet.Cells["A4"].PutValue(200);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(60);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(32);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a sample value to "B4" cell
worksheet.Cells["B4"].PutValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.Cells["C1"].PutValue("Q1");
//Adding a sample value to "C2" cell as category data
worksheet.Cells["C2"].PutValue("Q2");
//Adding a sample value to "C3" cell as category data
worksheet.Cells["C3"].PutValue("Y1");
//Adding a sample value to "C4" cell as category data
worksheet.Cells["C4"].PutValue("Y2");
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
int seriesIndex = chart.NSeries.Add("A1:B4", true);
//Setting the data source for the category data of NSeries
chart.NSeries.CategoryData = "C1:C4";
//Filling the area of the 2nd NSeries with a gradient
chart.NSeries[seriesIndex].Area.FillFormat.SetOneColorGradient(Color.Lime, 1, GradientStyleType.Horizontal, 1);
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Excel object
Dim sheetIndex As Int32 = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "A4" cell
worksheet.Cells("A4").PutValue(200)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(60)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(32)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a sample value to "B4" cell
worksheet.Cells("B4").PutValue(40)
'Adding a sample value to "C1" cell as category data
worksheet.Cells("C1").PutValue("Q1")
'Adding a sample value to "C2" cell as category data
worksheet.Cells("C2").PutValue("Q2")
'Adding a sample value to "C3" cell as category data
worksheet.Cells("C3").PutValue("Y1")
'Adding a sample value to "C4" cell as category data
worksheet.Cells("C4").PutValue("Y2")
'Adding a chart to the worksheet
Dim chartIndex As Int32 = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
Dim seriesIndex As Int32 = chart.NSeries.Add("A1:B4", True)
'Setting the data source for the category data of NSeries
chart.NSeries.CategoryData = "C1:C4"
'Filling the area of the 2nd NSeries with a gradient
chart.NSeries(seriesIndex).Area.FillFormat.SetOneColorGradient(Color.Lime, 1, GradientStyleType.Horizontal, 1)
Properties
FillType
Gets and sets fill type
public FillType FillType { get; set; }
Property Value
GradientColor1
Returns the gradient color 1 for the specified fill.
public Color GradientColor1 { get; }
Property Value
GradientColor2
Returns the gradient color 2 for the specified fill.
public Color GradientColor2 { get; }
Property Value
Remarks
Only when the gradient color type is GradientColorType.TwoColors, this property is meaningful.
GradientColorType
Returns the gradient color type for the specified fill.
public GradientColorType GradientColorType { get; }
Property Value
GradientDegree
Returns the gradient degree for the specified fill. Only applies for Excel 2007.
public double GradientDegree { get; }
Property Value
Remarks
Can only be a value from 0.0 (dark) through 1.0 (light).
GradientFill
Gets Aspose.Cells.Drawing.FillFormat.GradientFill object.
public GradientFill GradientFill { get; }
Property Value
GradientStyle
Returns the gradient style for the specified fill.
public GradientStyleType GradientStyle { get; }
Property Value
GradientVariant
Returns the gradient variant for the specified fill. Only applies for Excel 2007.
public int GradientVariant { get; }
Property Value
Remarks
Can only be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the Variant argument can only be 1 or 2.
ImageData
Gets and sets the picture image data.
public byte[] ImageData { get; set; }
Property Value
byte[]
Remarks
If the fill format is not custom texture format, returns null.
Pattern
Represents an area’s display pattern.
public FillPattern Pattern { get; set; }
Property Value
PatternFill
Gets Aspose.Cells.Drawing.FillFormat.PatternFill object.
public PatternFill PatternFill { get; }
Property Value
PictureFormatType
Gets and sets the picture format type.
public FillPictureType PictureFormatType { get; set; }
Property Value
PresetColor
Returns the gradient preset color for the specified fill.
public GradientPresetType PresetColor { get; }
Property Value
Scale
Gets and sets the picture format scale.
public double Scale { get; set; }
Property Value
SolidFill
Gets Aspose.Cells.Drawing.FillFormat.SolidFill object.
public SolidFill SolidFill { get; }
Property Value
Texture
Represents the texture type for the specified fill.
public TextureType Texture { get; set; }
Property Value
TextureFill
Gets Aspose.Cells.Drawing.FillFormat.TextureFill object.
public TextureFill TextureFill { get; }
Property Value
Transparency
Returns or sets the degree of transparency of the area as a value from 0.0 (opaque) through 1.0 (clear).
public double Transparency { get; set; }
Property Value
Methods
Equals(object)
public override bool Equals(object obj)
Parameters
obj
object
Returns
GetHashCode()
Gets the hash code.
public override int GetHashCode()
Returns
SetOneColorGradient(Color, double, GradientStyleType, int)
Sets the specified fill to a one-color gradient. Only applies for Excel 2007.
public void SetOneColorGradient(Color color, double degree, GradientStyleType style, int variant)
Parameters
color
Color
One gradient color.
degree
double
The gradient degree. Can be a value from 0.0 (dark) through 1.0 (light).
style
GradientStyleType
Gradient shading style.
variant
int
The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the Variant argument can only be 1 or 2.
SetPresetColorGradient(GradientPresetType, GradientStyleType, int)
Sets the specified fill to a preset-color gradient. Only applies for Excel 2007.
public void SetPresetColorGradient(GradientPresetType presetColor, GradientStyleType style, int variant)
Parameters
presetColor
GradientPresetType
Preset color type
style
GradientStyleType
Gradient shading style.
variant
int
The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the Variant argument can only be 1 or 2.
SetTwoColorGradient(Color, Color, GradientStyleType, int)
Sets the specified fill to a two-color gradient. Only applies for Excel 2007.
public void SetTwoColorGradient(Color color1, Color color2, GradientStyleType style, int variant)
Parameters
color1
Color
One gradient color.
color2
Color
Two gradient color.
style
GradientStyleType
Gradient shading style.
variant
int
The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the Variant argument can only be 1 or 2.
SetTwoColorGradient(Color, double, Color, double, GradientStyleType, int)
Sets the specified fill to a two-color gradient. Only applies for Excel 2007.
public void SetTwoColorGradient(Color color1, double transparency1, Color color2, double transparency2, GradientStyleType style, int variant)
Parameters
color1
Color
One gradient color.
transparency1
double
The degree of transparency of the color1 as a value from 0.0 (opaque) through 1.0 (clear).
color2
Color
Two gradient color.
transparency2
double
The degree of transparency of the color2 as a value from 0.0 (opaque) through 1.0 (clear).
style
GradientStyleType
Gradient shading style.
variant
int
The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the Variant argument can only be 1 or 2.