XlColorFilter.PatternType Property
Gets or sets the type of the pattern used in the filter criteria.
Namespace: DevExpress.Export.Xl
Assembly: DevExpress.Printing.v20.1.Core.dll
NuGet Packages: DevExpress.Printing.Core, DevExpress.WindowsDesktop.Printing.Core
Declaration
Property Value
Type | Description |
---|---|
XlPatternType | An XlPatternType enumeration member that specifies the type of the pattern fill used as a filter criterion. |
Available values:
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. |
DarkGray | Specifies the 75% gray pattern. |
LightGray | Specifies the 25% gray pattern. |
DarkHorizontal | Specifies a pattern that is a series of thick horizontal stripes. |
DarkVertical | Specifies a pattern that is a series of thick vertical stripes. |
DarkDown | Specifies a pattern that is a series of thick downward diagonal stripes. |
DarkUp | Specifies a pattern that is a series of thick upward diagonal stripes. |
DarkGrid | Specifies the thick grid pattern. |
DarkTrellis | Specifies the thick diagonal trellis pattern. |
LightHorizontal | Specifies a pattern that is a series of thin horizontal stripes. |
LightVertical | Specifies a pattern that is a series of thin vertical stripes. |
LightDown | Specifies a pattern that is a series of thin downward diagonal stripes. |
LightUp | Specifies a pattern that is a series of thin upward diagonal stripes. |
LightGrid | Specifies the thin grid pattern. |
LightTrellis | Specifies the thin diagonal trellis pattern. |
Gray125 | Specifies the 12.5% gray pattern. |
Gray0625 | Specifies the 6.25% gray pattern. |
Remarks
To filter a column by a pattern fill applied to its cells, specify the following properties of the pattern style you wish to use as a filter criterion:
- XlColorFilter.Color - specifies the cell’s background color.
- PatternType - specifies the type of the pattern fill;
- XlColorFilter.PatternColor - specifies the foreground color of the pattern fill.
In addition, you should set the XlColorFilter.FilterByCellColor property to true to specify that the column is filtered by a cell fill, not a font color.
The following example demonstrates how to use a color filter to display cells to which a pattern fill is applied.
// Generate the header row.
using (IXlRow row = sheet.CreateRow())
row.BulkCells(new string[] { "Region", "Product", "Sales" }, headerRowFormatting);
// Start filtering data in the "Product" column by the specified pattern fill.
XlColorFilter filter = new XlColorFilter();
filter.Color = XlColor.FromArgb(0x00ffcc99);
filter.FilterByCellColor = true;
filter.PatternColor = XlColor.FromArgb(0x00ff0000);
filter.PatternType = XlPatternType.LightDown;
sheet.AutoFilterColumns.Add(new XlFilterColumn(1, filter));
sheet.BeginFiltering(sheet.DataRange);
// Generate data for the document.
string[] products = new string[] { "Camembert Pierrot", "Gorgonzola Telino", "Mascarpone Fabioli", "Mozzarella di Giovanni" };
int[] amount = new int[] { 6750, 4500, 3550, 4250, 5500, 6250, 5325, 4235 };
for (int i = 0; i < 8; i++)
{
using (IXlRow row = sheet.CreateRow())
{
using (IXlCell cell = row.CreateCell())
{
cell.Value = (i < 4) ? "East" : "West";
cell.ApplyFormatting(rowFormatting);
}
using (IXlCell cell = row.CreateCell())
{
cell.Value = products[i % 4];
cell.ApplyFormatting(rowFormatting);
if (i % 4 == 0)
cell.ApplyFormatting(XlFill.PatternFill(XlPatternType.LightDown, XlColor.FromArgb(0x00ffcc99), XlColor.FromArgb(0x00ff0000)));
}
using (IXlCell cell = row.CreateCell())
{
cell.Value = amount[i];
cell.ApplyFormatting(rowFormatting);
}
}
}
// Finish filtering.
sheet.EndFiltering();
The following image shows the result of the above-mentioned code’s execution (the workbook is opened in Microsoft® Excel®).