XL.Format.SetFillPattern
------------------------

Sets the fill pattern.

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

MBS( "XL.Format.SetFillPattern"; Book; Format; Value ) 

**MBS**( **"XL.Format.SetFillPattern";** /\* Sets the fill pattern. \*/  
**$Book**; /\* The reference number for the workbook.e.g. $ref \*/   
**$Format**; /\* The index of the format in the book to target.e.g. 0 \*/   
**$Value**) /\* The new pattern.e.g. 3 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Book | The reference number for the workbook. | $ref |
| Format | The index of the format in the book to target. | 0 |
| Value | The new pattern. | 3 |

### Result

Returns OK or error.

### Description

Sets the fill pattern.  
  
| None | 0 |
|---|--:|
| Solid | 1 |
| 50% Gray | 2 |
| 75% Gray | 3 |
| 25% Gray | 4 |
| Horizontal Stripes | 5 |
| Vertical Stripes | 6 |
| Reverse Diagonal Stripes | 7 |
| Diagonal Stripes | 8 |
| Diagonal Cross Hatch | 9 |
| Thick Diagonal Stripe | 9 |
| Thin Horizontal Stripe | 11 |
| Thin Vertical Stripe | 12 |
| Thin Reverse Diagonal Stripe | 13 |
| Thin Diagonal Stripe | 14 |
| Thin Horizontal Cross Hatch | 15 |
| Thin Diagonal Cross Hatch | 16 |
| Gray 12P5 | 17 |
| Gray 6P25 | 18 |

  
see table of fill patterns here:  
<http://www.libxl.com/format.html#borderStyleTable#setFillPattern>  
### Examples

Sets the foreground color of the fill pattern to red to fill cell red:

 If \[ MBS ( "[XL.Book.GetRGBMode](XLBookGetRGBMode.md)"; $book ) = 0 \]  
 Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetPatternForegroundColor](XLFormatSetPatternForegroundColor.md)"; $book ; $format ; 10) \]   
Else  
 Set Variable \[ $c ; Value: MBS ( "[XL.Color.Pack](XLColorPack.md)"; $book ; 255; 0; 0) \]  
 Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetPatternForegroundColor](XLFormatSetPatternForegroundColor.md)"; $book ; $format ; $c ) \]   
End If  
Set Variable \[ $r ; Value: MBS ( "XL.Format.SetFillPattern"; $book ; $format ; 1 ) \]  
### See also

- [XL.Book.AddFormat](XLBookAddFormat.md)
- [XL.Book.GetRGBMode](XLBookGetRGBMode.md)
- [XL.Color.Pack](XLColorPack.md)
- [XL.Format.GetFillPattern](XLFormatGetFillPattern.md)
- [XL.Format.SetAlignH](XLFormatSetAlignH.md)
- [XL.Format.SetPatternBackgroundColor](XLFormatSetPatternBackgroundColor.md)
- [XL.Format.SetPatternForegroundColor](XLFormatSetPatternForegroundColor.md)
- [XL.Sheet.CellWriteText](XLSheetCellWriteText.md)

This function checks for a license.

Created 18th August 2014 , last changed 30th March 2024

  
[XL.Format.SetBorderTopColor](XLFormatSetBorderTopColor.md) - [XL.Format.SetFont](XLFormatSetFont.md)

[HTML Version](XLFormatSetFillPattern.shtml)