XlFill.SolidFill(XlColor) Method
Creates the XlFill object that specifies the solid fill for a cell background.
Namespace: DevExpress.Export.Xl
Assembly: DevExpress.Printing.v24.1.Core.dll
NuGet Package: DevExpress.Printing.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
color | XlColor | An XlColor object that is the color used to fill a cell background. |
Returns
Type | Description |
---|---|
XlFill | An XlFill object that specifies the cell background fill. |
Remarks
Use the SolidFill method to specify the background color of a cell. This method automatically sets the XlFill.PatternType property to XlPatternType.Solid value and assigns the specified color to the XlFill.ForeColor property.
To apply the specified fill settings to a cell, pass the XlFill object to the IXlCell.ApplyFormatting method as a parameter, or assign it to the IXlCell.Formatting property.
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)));
}
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the SolidFill(XlColor) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.