Back to Devexpress

SpreadsheetFont.Color Property

officefileapi-devexpress-dot-spreadsheet-dot-spreadsheetfont.md

latest11.6 KB
Original Source

SpreadsheetFont.Color Property

Gets or sets the color of the font applied to the cell content.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
Color Color { get; set; }
vb
Property Color As Color

Property Value

TypeDescription
Color

A Color structure that specifies the font color.

|

Remarks

To specify all the required font characteristics, use the SpreadsheetFont object properties such as SpreadsheetFont.Name, SpreadsheetFont.FontStyle, SpreadsheetFont.Size, SpreadsheetFont.Script, etc. Access this object via the Formatting.Font property.

For examples on how to specify formatting for an individual cell and cell range or modify a style, refer to the How to: Format a Cell or Range of Cells or How to: Create or Modify a Style documents.

To specify the background of a cell or range of cells (background color, pattern type and pattern color), modify the Fill object accessed via the Formatting.Fill property. For details, review the How to: Change Cell Font and Background Color example.

Note

SpreadsheetControl does not display cell text with a semi-transparent color.

Example

This example demonstrates how to format cell font characteristics (e.g., font name, size, color, style) by modifying the SpreadsheetFont object accessed via the Formatting.Font property of the Cell object.

View Example

csharp
// Access the Font object.
SpreadsheetFont cellFont = worksheet.Cells["A1"].Font;
// Set the font name.
cellFont.Name = "Times New Roman";
// Set the font size.
cellFont.Size = 14;
// Set the font color.
cellFont.Color = Color.Blue;
// Format text as bold.
cellFont.Bold = true;
// Set font to be underlined.
cellFont.UnderlineType = UnderlineType.Single;
vb
' Access the Font object.
Dim cellFont As SpreadsheetFont = worksheet.Cells("A1").Font
' Set the font name.
cellFont.Name = "Times New Roman"
' Set the font size.
cellFont.Size = 14
' Set the font color.
cellFont.Color = Color.Blue
' Format text as bold.
cellFont.Bold = True
' Set font to be underlined.
cellFont.UnderlineType = UnderlineType.Single

The following code snippets (auto-collected from DevExpress Examples) contain references to the Color 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-apply-conditional-formatting-to-cell-range/CS/ConditionalFormatting_Example/SpreadsheetActions/ConditionalFormatting.cs#L45

csharp
// Set the font color to red.
cfRule1.Formatting.Font.Color = Color.Red;
// Create the rule highlighting values that are one standard deviation below the mean in cells D2 through D15.

winforms-spreadsheet-apply-conditional-formatting-to-a-range-of-cells/CS/SpreadsheetControl/SpreadsheetActions/ConditionalFormatting.cs#L43

csharp
// Set the font color to red.
cfRule1.Formatting.Font.Color = Color.Red;
// Create the rule highlighting values that are one standard deviation below the mean in cells D2 through D15.

wpf-spreadsheet-how-to-apply-conditional-formatting-to-a-range-of-cells/CS/ConditionalFormatting_WPF_Examples/SpreadsheetActions/ConditionalFormatting.cs#L42

csharp
// Set the font color to red.
cfRule1.Formatting.Font.Color = Color.Red;
// Create the rule highlighting values that are one standard deviation below the mean in cells D2 through D15.

spreadsheet-document-api-examples-part1/CS/SpreadsheetExamples/SpreadsheetActions/WorksheetActions.cs#L95

csharp
sourceWorkbook.Worksheets[1].Cells["A1"].Value = "A worksheet to be copied";
sourceWorkbook.Worksheets[1].Cells["A1"].Font.Color = Color.ForestGreen;

spreadsheet-document-api-examples-part2/CS/SpreadsheetDocServerAPIPart2/CodeExamples/AutoFilterActions.cs#L71

csharp
List<SortCondition> sortConditions = new List<SortCondition>();
Color color = worksheet["D12"].Font.Color;

spreadsheet-document-api-examples-part1/VB/SpreadsheetExamples/SpreadsheetActions/FormattingActions.vb#L55

vb
' Specify the font color.
myStyle.Font.Color = Color.Blue
' Specify the font size.

spreadsheet-document-api-apply-conditional-formatting-to-cell-range/VB/ConditionalFormatting_Example/SpreadsheetActions/ConditionalFormatting.vb#L50

vb
' Set the font color to red.
cfRule1.Formatting.Font.Color = Color.Red
' Create the rule highlighting values that are one standard deviation below the mean in cells D2 through D15.

winforms-spreadsheet-apply-conditional-formatting-to-a-range-of-cells/VB/SpreadsheetControl/SpreadsheetActions/ConditionalFormatting.vb#L42

vb
' Set the font color to red.
cfRule1.Formatting.Font.Color = Color.Red
' Create the rule highlighting values that are one standard deviation below the mean in cells D2 through D15.

wpf-spreadsheet-how-to-apply-conditional-formatting-to-a-range-of-cells/VB/ConditionalFormatting_WPF_Examples/SpreadsheetActions/ConditionalFormatting.vb#L40

vb
' Set the font color to red.
cfRule1.Formatting.Font.Color = Color.Red
' Create the rule highlighting values that are one standard deviation below the mean in cells D2 through D15.

spreadsheet-document-api-examples-part2/VB/SpreadsheetDocServerAPIPart2/CodeExamples/AutoFilterActions.vb#L66

vb
Dim sortConditions As New List(Of SortCondition)()
Dim color As Color = worksheet("D12").Font.Color

See Also

Name

FontStyle

Size

Script

Strikethrough

UnderlineType

WinForms Spreadsheet Control Examples

SpreadsheetFont Interface

SpreadsheetFont Members

DevExpress.Spreadsheet Namespace