Formatting.Fill Property
Provides access to cell background.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v19.1.Core.dll
Declaration
Property Value
Type | Description |
---|---|
Fill | A Fill object providing properties to change cell background characteristics. |
Remarks
Use properties of the Fill object to customize the cell background. For example, you can fill cells with solid colors (Fill.BackgroundColor, Range.FillColor), shade cells with patterns (Fill.PatternType, Fill.PatternColor) or apply gradient effect (Fill.Gradient).
- To specify the background of an individual cell, use the Cell object’s Fill property that is inherited form the Formatting interface.
- To specify the background of a range of cells, call the Range.BeginUpdateFormatting method for this range, set the Fill property of the returned Formatting object and call the Range.EndUpdateFormatting method to finalize the modification.
- To share the same background settings between multiple cells in a single step, create or modify the style with the Fill property specified as required, and assign this style to Range.Style for the desired cells.
Example
This example demonstrates how to format color characteristics (font and background colors) for an individual cell and range of cells.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/spreadsheet-document-server-api-e4339
// Format an individual cell.
worksheet.Cells["A1"].Font.Color = Color.Red;
worksheet.Cells["A1"].FillColor = Color.Yellow;
// Format a range of cells.
Range range = worksheet.Range["C3:D4"];
Formatting rangeFormatting = range.BeginUpdateFormatting();
rangeFormatting.Font.Color = Color.Blue;
rangeFormatting.Fill.BackgroundColor = Color.LightBlue;
rangeFormatting.Fill.PatternType = PatternType.LightHorizontal;
rangeFormatting.Fill.PatternColor = Color.Violet;
range.EndUpdateFormatting(rangeFormatting);
See Also