Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

XL.Font.SetColor

Sets the color of the font.

Component Version macOS Windows Linux Server iOS SDK
XL 3.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XL.Font.SetColor"; book; Font; Value )   More

Parameters

Parameter Description Example
book The reference to the workbook. Please use XL.LoadBook to load a file. $ref
Font The index of the font in the book to target. 0
Value The new font color. 255

Result

Returns OK or error.

Description

Sets the color of the font.
If you set value and book is in RGB mode you can use XL.ColorPack function to get a numeric value for color components. If the book is not in RGB mode, you can use color values as described below.

Color values if not in RGB Mode:
Black8
White9
Red10
Brightgreen11
Blue12
Yellow13
Pink14
Turquoise15
Darkred16
Green17
Darkblue18
Darkyellow19
Violet20
Teal21
Gray2522
Gray5023
Periwinkle Cf24
Plum Cf25
Ivory Cf26
Lightturquoise Cf27
Darkpurple Cf28
Coral Cf29
Oceanblue Cf30
Iceblue Cf31
Darkblue Cl32
Pink Cl33
Yellow Cl34
Turquoise Cl35
Violet Cl36
Darkred Cl37
Teal Cl38
Blue Cl39
Skyblue40
Lightturquoise41
Lightgreen42
Lightyellow43
Paleblue44
Rose45
Lavender46
Tan47
Lightblue48
Aqua49
Lime50
Gold51
Lightorange52
Orange53
Bluegray54
Gray4055
Darkteal56
Seagreen57
Darkgreen58
Olivegreen59
Brown60
Plum61
Indigo62
Gray8063
Default Foreground64
Default Background65
Tooltip81
Auto32767

Examples

Make a font blue in non RGB mode:

MBS( "XL.Font.SetColor"; $book; $font10; 12 )

Writes sheet with red font:

#create new xls file
Set Variable [$book; Value:MBS( "XL.NewBook"; 0 )]
#create fonts
Set Variable [$redColor; Value:MBS( "XL.Color.Pack"; $book; 255; 0; 0)]
Set Variable [$redFont; Value:MBS( "XL.Book.AddFont"; $book)]
Set Variable [$r; Value:MBS( "XL.Font.SetColor"; $book; $redFont; $redColor)]
#
#create formats
Set Variable [$redFormat; Value:MBS( "XL.Book.AddFormat"; $book)]
Set Variable [$r; Value:MBS( "XL.Format.SetFont"; $book; $redFormat; $redFont)]
#
#create sheet
Set Variable [$sheet; Value:MBS( "XL.Book.AddSheet"; $book; "Sales Receipt")]
#
#add number in red
Set Variable [$r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 5; 3; 123; $redFormat)]
#
Set Field [Writing data::Output; MBS("XL.Book.Save"; $book; "test.xls")]
Set Variable [$r; Value:MBS("XL.Book.Release"; $book)]

Create font with color 22:

Set Variable [$titleFont; Value:MBS( "XL.Book.AddFont"; $book)]
Set Variable [$r; Value:MBS( "XL.Font.SetColor"; $book; $titlefont; 22)]

See also

Example Databases

This function checks for a license.

Created 18th August 2014, last changed 5th May 2016


XL.Font.SetBold - XL.Font.SetItalic