ExcelScript.ConditionalRangeFormat interface
A format object encapsulating the conditional formats range's font, fill, borders, and other properties.
Remarks
Examples
/**
* This script applies cell value conditional formatting to a range.
* Any value less than 60 will have the cell's fill color changed and the font made italic.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the range to format.
const selectedRange = workbook.getSelectedRange();
// Add cell value conditional formatting.
const cellValueConditionalFormatting =
selectedRange.addConditionalFormat(ExcelScript.ConditionalFormatType.cellValue).getCellValue();
// Create the condition, in this case when the cell value is less than 60.
const rule: ExcelScript.ConditionalCellValueRule = {
formula1: "60",
operator: ExcelScript.ConditionalCellValueOperator.lessThan
};
cellValueConditionalFormatting.setRule(rule);
// Set the format to apply when the condition is met.
const format: ExcelScript.ConditionalRangeFormat = cellValueConditionalFormatting.getFormat();
format.getFill().setColor("yellow");
format.getFont().setItalic(true);
}
Methods
get |
Collection of border objects that apply to the overall conditional format range. |
get |
Gets a border object using its name. |
get |
Gets the bottom border. |
get |
Gets the left border. |
get |
Gets the right border. |
get |
Gets the top border. |
get |
Returns the fill object defined on the overall conditional format range. |
get |
Returns the font object defined on the overall conditional format range. |
get |
Represents Excel's number format code for the given range. Cleared if |
set |
Represents Excel's number format code for the given range. Cleared if |
Method Details
getBorders()
Collection of border objects that apply to the overall conditional format range.
getBorders(): ConditionalRangeBorder[];
Returns
getConditionalRangeBorder(index)
Gets a border object using its name.
getConditionalRangeBorder(
index: ConditionalRangeBorderIndex
): ConditionalRangeBorder;
Parameters
Index value of the border object to be retrieved. See ExcelScript.ConditionalRangeBorderIndex
for details.
Returns
getConditionalRangeBorderBottom()
Gets the bottom border.
getConditionalRangeBorderBottom(): ConditionalRangeBorder;
Returns
getConditionalRangeBorderLeft()
Gets the left border.
getConditionalRangeBorderLeft(): ConditionalRangeBorder;
Returns
getConditionalRangeBorderRight()
Gets the right border.
getConditionalRangeBorderRight(): ConditionalRangeBorder;
Returns
getConditionalRangeBorderTop()
Gets the top border.
getConditionalRangeBorderTop(): ConditionalRangeBorder;
Returns
getFill()
Returns the fill object defined on the overall conditional format range.
getFill(): ConditionalRangeFill;
Returns
getFont()
Returns the font object defined on the overall conditional format range.
getFont(): ConditionalRangeFont;
Returns
getNumberFormat()
Represents Excel's number format code for the given range. Cleared if null
is passed in.
getNumberFormat(): string;
Returns
string
setNumberFormat(numberFormat)
Represents Excel's number format code for the given range. Cleared if null
is passed in.
setNumberFormat(numberFormat: string): void;
Parameters
- numberFormat
-
string
Returns
void
Office Scripts