FillFormat class

FillFormat class

Encapsulates the object that represents fill formatting for a shape.

The FillFormat type exposes the following members:

Properties

PropertyDescription
typeGets and sets the fill type.
fill_typeGets and sets fill type
transparencyReturns or sets the degree of transparency of the area as a value from 0.0 (opaque) through 1.0 (clear).
set_typeGets the fill format set type.
gradient_fillGets FillFormat.gradient_fill object.
texture_fillGets FillFormat.texture_fill object.
solid_fillGets FillFormat.solid_fill object.
pattern_fillGets FillFormat.pattern_fill object.
gradient_color_typeReturns the gradient color type for the specified fill.
gradient_styleReturns the gradient style for the specified fill.
gradient_color1Returns the gradient color 1 for the specified fill.
gradient_color2Returns the gradient color 2 for the specified fill.
gradient_degreeReturns the gradient degree for the specified fill.
Only applies for Excel 2007.
gradient_variantReturns the gradient variant for the specified fill.
Only applies for Excel 2007.
preset_colorReturns the gradient preset color for the specified fill.
textureRepresents the texture type for the specified fill.
patternRepresents an area’s display pattern.
picture_format_typeGets and sets the picture format type.
scaleGets and sets the picture format scale.
image_dataGets and sets the picture image data.

Methods

MethodDescription
set_two_color_gradientSets the specified fill to a two-color gradient.
Only applies for Excel 2007.
set_two_color_gradientSets the specified fill to a two-color gradient.
Only applies for Excel 2007.
set_one_color_gradientSets the specified fill to a one-color gradient.
Only applies for Excel 2007.
set_preset_color_gradientSets the specified fill to a preset-color gradient.
Only applies for Excel 2007.

Example

from aspose.cells import Workbook
from aspose.cells.charts import ChartType
from aspose.cells.drawing import GradientStyleType
from aspose.pydrawing import Color

# Instantiating a Workbook object
workbook = Workbook()
# Adding a new worksheet to the Excel object
sheetIndex = workbook.worksheets.add()
# Obtaining the reference of the newly added worksheet by passing its sheet index
worksheet = workbook.worksheets[sheetIndex]
# Adding a sample value to "A1" cell
worksheet.cells.get("A1").put_value(50)
# Adding a sample value to "A2" cell
worksheet.cells.get("A2").put_value(100)
# Adding a sample value to "A3" cell
worksheet.cells.get("A3").put_value(150)
# Adding a sample value to "A4" cell
worksheet.cells.get("A4").put_value(200)
# Adding a sample value to "B1" cell
worksheet.cells.get("B1").put_value(60)
# Adding a sample value to "B2" cell
worksheet.cells.get("B2").put_value(32)
# Adding a sample value to "B3" cell
worksheet.cells.get("B3").put_value(50)
# Adding a sample value to "B4" cell
worksheet.cells.get("B4").put_value(40)
# Adding a sample value to "C1" cell as category data
worksheet.cells.get("C1").put_value("Q1")
# Adding a sample value to "C2" cell as category data
worksheet.cells.get("C2").put_value("Q2")
# Adding a sample value to "C3" cell as category data
worksheet.cells.get("C3").put_value("Y1")
# Adding a sample value to "C4" cell as category data
worksheet.cells.get("C4").put_value("Y2")
# Adding a chart to the worksheet
chartIndex = worksheet.charts.add(ChartType.COLUMN, 5, 0, 15, 5)
# Accessing the instance of the newly added chart
chart = worksheet.charts[chartIndex]
# Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
seriesIndex = chart.n_series.add("A1:B4", True)
# Setting the data source for the category data of NSeries
chart.n_series.category_data = "C1:C4"
# Filling the area of the 2nd NSeries with a gradient
chart.n_series[seriesIndex].area.fill_format.set_one_color_gradient(Color.lime, 1, GradientStyleType.HORIZONTAL, 1)

See Also