GradientFill Class

Gradient.When the object is serialized out as xml, its qualified name is x:gradientFill.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlCompositeElement
      DocumentFormat.OpenXml.Spreadsheet.GradientFill

Namespace:  DocumentFormat.OpenXml.Spreadsheet
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

Syntax

'Declaration
<ChildElementInfoAttribute(GetType(GradientStop))> _
Public Class GradientFill _
    Inherits OpenXmlCompositeElement
'Usage
Dim instance As GradientFill
[ChildElementInfoAttribute(typeof(GradientStop))]
public class GradientFill : OpenXmlCompositeElement

Remarks

The following table lists the possible child types:

  • GradientStop <x:stop>

[ISO/IEC 29500-1 1st Edition]

18.8.24 gradientFill (Gradient)

This element defines a gradient-style cell fill. Gradient cell fills can use one or two colors as the end points of color interpolation.

[Example:

This example shows a gradient cell fill, with color green at the top transitioning into blue at the bottom.

DocumentFormat.OpenXml.Spreadsheet.GradientFill-im

This is the XML:

<fill>
<gradientFill degree="90">
<stop position="0">
<color rgb="FF92D050"/>
</stop>
    <stop position="1">
<color rgb="FF0070C0"/>
</stop>
</gradientFill>
</fill>

This example shows a gradient cell fill, from the center. Note the left, right, top, and bottom values (and see explanation in the attribute section):

DocumentFormat.OpenXml.Spreadsheet.GradientFill-im

<fill>
<gradientFill type="path" left="0.2" right="0.8" top="0.2" bottom="0.8">
<stop position="0">
<color theme="0"/>
</stop>
    <stop position="1">
<color theme="4"/>
</stop>
</gradientFill>
</fill>

end example]

Parent Elements

fill (§18.8.20)

Child Elements

Subclause

stop (Gradient Stop)

§18.8.38

Attributes

Description

bottom (Bottom Convergence)

This attribute is restricted to values ranging from 0 to 1. Specifies in percentage format (from the top to the bottom) the position of the bottom edge of the inner rectangle (color 1). For bottom, 0 means the bottom edge of the inner rectangle is on the top edge of the cell, and 1 means it is on the bottom edge of the cell.

The possible values for this attribute are defined by the W3C XML Schema double datatype.

degree (Linear Gradient Degree)

Angle of the linear gradient - vertical, horizontal, diagonal.

[Example:

In these examples, color 1 is white and color 2 is blue.

90 = Horizontal & color 1 to color 2

DocumentFormat.OpenXml.Spreadsheet.GradientFill-im

270 = Horizontal & color 1 to color 2

DocumentFormat.OpenXml.Spreadsheet.GradientFill-im

0 = Vertical & color 1 to color 2

DocumentFormat.OpenXml.Spreadsheet.GradientFill-im

180 = Vertical & color 1 to color 2

DocumentFormat.OpenXml.Spreadsheet.GradientFill-im

45 = Diagonal Up & top to bottom (color 1 to color 2)

225 = Diagonal Up & bottom to top (color 1 to color 2)

135 = Diagonal Down & top to bottom (color 1 to color 2)

315 = Diagonal Down & bottom to top (color 1 to color 2)

end example]

The possible values for this attribute are defined by the W3C XML Schema double datatype.

left (Left Convergence)

This attribute is restricted to values ranging from 0 to 1. Specifies in percentage format (from the left to the right) the position of the left edge of the inner rectangle (color 1). For left, 0 means the left edge of the inner rectangle is on the left edge of the cell, and 1 means it is on the right edge of the cell. (applies to From Corner and From Center gradients).

The possible values for this attribute are defined by the W3C XML Schema double datatype.

right (Right Convergence)

This attribute is restricted to values ranging from 0 to 1. Specifies in percentage format (from the left to the right) the position of the right edge of the inner rectangle (color 1). For right, 0 means the right edge of the inner rectangle is on the left edge of the cell, and 1 means it is on the right edge of the cell. (applies to From Corner and From Center gradients).

The possible values for this attribute are defined by the W3C XML Schema double datatype.

top (Top Gradient Convergence)

This attribute is restricted to values ranging from 0 to 1. Specifies in percentage format (from the top to the bottom) the position of the top edge of the inner rectangle (color 1). For top, 0 means the top edge of the inner rectangle is on the top edge of the cell, and 1 means it is on the bottom edge of the cell. (applies to From Corner and From Center gradients).

The possible values for this attribute are defined by the W3C XML Schema double datatype.

type (Gradient Fill Type)

Type of this gradient fill.

The possible values for this attribute are defined by the ST_GradientType simple type (§18.18.37).

[Note: The W3C XML Schema definition of this element’s content model (CT_GradientFill) is located in §A.2. end note]

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

GradientFill Members

DocumentFormat.OpenXml.Spreadsheet Namespace