Skip to main content

XlFill.PatternType Property

Gets or sets the type of the pattern applied to a cell background.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v24.1.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

public XlPatternType PatternType { get; set; }

Property Value

Type Description
XlPatternType

An XlPatternType enumeration member that is a preset type of pattern fill.

Available values:

Show 19 items
Name Description
None

No background (solid color or fill pattern) is applied to a cell.

Solid

Specifies that a cell is filled with a solid color.

MediumGray

Specifies the 50% gray pattern.

PatternType_MediumGray

DarkGray

Specifies the 75% gray pattern.

PatternType_DarkGray

LightGray

Specifies the 25% gray pattern.

PatternType_LightGray

DarkHorizontal

Specifies a pattern that is a series of thick horizontal stripes.

PatternType_DarkHorizontal

DarkVertical

Specifies a pattern that is a series of thick vertical stripes.

PatternType_DarkVertical

DarkDown

Specifies a pattern that is a series of thick downward diagonal stripes.

PatternType_DarkDown

DarkUp

Specifies a pattern that is a series of thick upward diagonal stripes.

PatternType_DarkUp

DarkGrid

Specifies the thick grid pattern.

PatternType_DarkGrid

DarkTrellis

Specifies the thick diagonal trellis pattern.

PatternType_DarkTrellis

LightHorizontal

Specifies a pattern that is a series of thin horizontal stripes.

PatternType_LightHorizontal

LightVertical

Specifies a pattern that is a series of thin vertical stripes.

PatternType_LightVertical

LightDown

Specifies a pattern that is a series of thin downward diagonal stripes.

PatternType_LightDown

LightUp

Specifies a pattern that is a series of thin upward diagonal stripes.

PatternType_LightUp

LightGrid

Specifies the thin grid pattern.

PatternType_LightGrid

LightTrellis

Specifies the thin diagonal trellis pattern.

PatternType_LightTrellis

Gray125

Specifies the 12.5% gray pattern.

PatternType_Gray125

Gray0625

Specifies the 6.25% gray pattern.

PatternType_Gray0625

Remarks

Use the XlFill.PatternFill method to specify a pattern style for a cell. The XlFill.BackColor and XlFill.ForeColor properties allow you to control the background color and foreground color of the cell fill pattern.

By default, the PatternType property is set to XlPatternType.None. When you use the XlFill.SolidFill method to color the cell background, the PatternType property value is automatically changed to XlPatternType.Solid.

For more information on how to set the background characteristics of a cell, refer to the How to: Change Cell Background Color example.

Example

Note

A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples

// Create a new worksheet.
using(IXlSheet sheet = document.CreateSheet()) {

    using(IXlRow row = sheet.CreateRow()) {
        using(IXlCell cell = row.CreateCell()) {
            // Fill the cell background using the predefined color.
            cell.ApplyFormatting(XlFill.SolidFill(Color.Beige));
        }
        using(IXlCell cell = row.CreateCell()) {
            // Fill the cell background using the custom RGB color.
            cell.ApplyFormatting(XlFill.SolidFill(Color.FromArgb(0xff, 0x99, 0x66)));
        }
        using(IXlCell cell = row.CreateCell()) {
            // Fill the cell background using the theme color.
            cell.ApplyFormatting(XlFill.SolidFill(XlColor.FromTheme(XlThemeColor.Accent3, 0.4)));
        }
    }

    using(IXlRow row = sheet.CreateRow()) {
        using(IXlCell cell = row.CreateCell()) {
            // Specify the cell background pattern using predefined colors.
            cell.ApplyFormatting(XlFill.PatternFill(XlPatternType.DarkDown, Color.Red, Color.White));
        }
        using(IXlCell cell = row.CreateCell()) {
            // Specify the cell background pattern using custom RGB colors.
            cell.ApplyFormatting(XlFill.PatternFill(XlPatternType.DarkTrellis, Color.FromArgb(0xff, 0xff, 0x66), Color.FromArgb(0x66, 0x99, 0xff)));
        }
        using(IXlCell cell = row.CreateCell()) {
            // Specify the cell background pattern using theme colors.
            cell.ApplyFormatting(XlFill.PatternFill(XlPatternType.LightHorizontal, XlColor.FromTheme(XlThemeColor.Accent1, 0.2), XlColor.FromTheme(XlThemeColor.Light2, 0.0)));
        }
    }
}
See Also