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

XL.Sheet.SetCellFormat

Sets cell's format.

Component Version macOS Windows Linux Server iOS SDK
XL 3.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XL.Sheet.SetCellFormat"; bookRef; sheetIndex; Row; Column; Format )   More

Parameters

Parameter Description Example
bookRef The reference to the workbook. Please use XL.LoadBook to load a file. $ref
sheetIndex The index of the sheet. This number ranges from 0 to XL.Book.SheetCount-1. 0
Row The row for the cell. First row has index 0. $row
Column The column for the cell. First column has index 0. $column
Format The format for the cell. This is index from 0 to XL.GetFormatCount-1 in the book's list of formats. 0

Result

Returns OK or error.

Description

Sets cell's format.

Examples

Apply a new format to a column:

#create new format
Set Variable [$format; Value:MBS( "XL.Book.AddFormat"; $BookRef )]
Set Variable [$r; Value:MBS( "XL.Format.SetNumFormat"; $BookRef; $format; 7)]
#set as format for column
Set Variable [$r; Value:MBS( "XL.Sheet.SetColumn"; $BookRef; 0; 6; 6; 50 ; $format; 0 )]
#loop over all rows
Set Variable [$lastRow; Value:MBS( "XL.Sheet.GetLastRow"; $BookRef; $sheet )]
Set Variable [$row; Value:1]
Loop
    Set Variable [$r; Value:MBS( "XL.Sheet.SetCellFormat"; $BookRef; $sheet; $row; 6; $format )]
    #next
    Set Variable [$row; Value:$row + 1]
    Exit Loop If [$row > $lastRow]
End Loop

See also

Release notes

This function checks for a license.

Created 18th August 2014, last changed 24th March 2016


XL.Sheet.SetAutoFitArea - XL.Sheet.SetCellFormats