Back to Devexpress

Formatting.Fill Property

officefileapi-devexpress-dot-spreadsheet-dot-formatting.md

latest7.4 KB
Original Source

Formatting.Fill Property

Provides access to cell background.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
Fill Fill { get; }
vb
ReadOnly Property Fill As Fill

Property Value

TypeDescription
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, CellRange.FillColor), shade cells with patterns (Fill.PatternType, Fill.PatternColor) or apply gradient effect (Fill.Gradient).

Example

The following example specifies font and background colors for an individual cell and cell range:

View Example: Spreadsheet Document API Examples

csharp
using DevExpress.Spreadsheet;
using System.Drawing;
// ...

// Format an individual cell.
worksheet.Cells["A1"].Font.Color = Color.Red;
worksheet.Cells["A1"].FillColor = Color.Yellow;

// Format a cell range.
CellRange 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);
vb
Imports DevExpress.Spreadsheet
Imports System.Drawing
' ...

' Format an individual cell.
worksheet.Cells("A1").Font.Color = Color.Red
worksheet.Cells("A1").FillColor = Color.Yellow

' Format a cell range.
Dim range As CellRange = worksheet.Range("C3:D4")
Dim rangeFormatting As Formatting = 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)

The following code snippets (auto-collected from DevExpress Examples) contain references to the Fill property.

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.

spreadsheet-document-api-examples-part2/CS/SpreadsheetDocServerAPIPart2/CodeExamples/SortActions.cs#L116

csharp
CellRange range = worksheet.Range["A3:F22"];
worksheet.Sort(range, 0, worksheet["A3"].Fill);

winforms-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_API_Part02/SpreadsheetActions/SortActions.cs#L146

csharp
CellRange range = worksheet.Range["A3:F22"];
worksheet.Sort(range, 0, worksheet["A3"].Fill);

wpf-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/SortActions.cs#L153

csharp
CellRange range = worksheet.Range["A3:F22"];
worksheet.Sort(range, 0, worksheet["A3"].Fill);

spreadsheet-document-api-examples-part2/VB/SpreadsheetDocServerAPIPart2/CodeExamples/SortActions.vb#L109

vb
Dim range As CellRange = worksheet.Range("A3:F22")
worksheet.Sort(range, 0, worksheet("A3").Fill)

wpf-spreadsheetcontrol-api-part-1/VB/SpreadsheetControl_WPF_API/SpreadsheetActions/FormattingActions.vb#L309

vb
' Specify a linear gradient fill for a cell.
Dim fillA1 As Fill = worksheet.Cells("A1").Fill
fillA1.FillType = FillType.Gradient

See Also

How to: Change Cell Font and Background Color

How to: Clear Cell Formatting

Formatting Interface

Formatting Members

DevExpress.Spreadsheet Namespace