XL.Color.Pack
-------------

Packs red, green and blue components in color type.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XL](component_XL.md) | [3.5](newinversion35.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XL.Color.Pack"; BookRef; Red; Green; Blue ) 

**MBS**( **"XL.Color.Pack";** /\* Packs red, green and blue components in color type. \*/  
**$BookRef**; /\* The reference number for the workbook.e.g. $ref \*/   
**$Red**; /\* The red color value from 0 to 255.e.g. 255 \*/   
**$Green**; /\* The green color value from 0 to 255.e.g. 255 \*/   
**$Blue**) /\* The blue color value from 0 to 255.e.g. 255 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| BookRef | The reference number for the workbook. | $ref |
| Red | The red color value from 0 to 255. | 255 |
| Green | The green color value from 0 to 255. | 255 |
| Blue | The blue color value from 0 to 255. | 255 |

### Result

Returns color value.

### Description

Packs red, green and blue components in color type.  
### Examples

Checks what color value to use for 100% red:

 MBS ( "XL.Color.Pack"; $$book ; 255; 0; 0)  
// shows 10 in indexed color mode  
// shows 16711680 in RGB mode  
Writes sheet with red font:

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

- [XL.Book.Save](XLBookSave.md)
- [XL.ConditionalFormating.Add2ColorScaleRule](XLConditionalFormatingAdd2ColorScaleRule.md)
- [XL.ConditionalFormating.AddRule](XLConditionalFormatingAddRule.md)
- [XL.Format.SetFillPattern](XLFormatSetFillPattern.md)
- [XL.Format.SetFont](XLFormatSetFont.md)
- [XL.Format.SetPatternBackgroundColor](XLFormatSetPatternBackgroundColor.md)
- [XL.NewBook](XLNewBook.md)
- [XL.Sheet.AddConditionalFormatting](XLSheetAddConditionalFormatting.md)
- [XL.Sheet.CellWriteNumber](XLSheetCellWriteNumber.md)
- [XL.Sheet.CellWriteText](XLSheetCellWriteText.md)

### Example Databases

- [XL/Conditional Formatting](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Conditional%20Formatting.shtml#2ScriptAnchor_)
- [XL/Writing data](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Writing%20data.shtml#7ScriptAnchor_)

### Blog Entries

- [Conditional Formatting in Excel exports from FileMaker](https://www.mbsplugins.de/archive/2024-04-08/Conditional_Formatting_in_Exce/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 23th June 2015

  
[XL.Book.Version](XLBookVersion.md) - [XL.Color.UnPack](XLColorUnPack.md)

[HTML Version](XLColorPack.shtml)