ExcelScript.TextConditionalFormat interface
Represents a specific text conditional format.
Remarks
Examples
/**
* This script adds conditional formatting to the first column in the worksheet.
* This formatting gives the cells a green fill if they have text starting with "Excel".
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first column in the current worksheet.
const currentSheet = workbook.getActiveWorksheet();
const firstColumn = currentSheet.getRange("A:A");
// Add conditional formatting based on the text in the cells.
const textConditionFormat: ExcelScript.TextConditionalFormat =
firstColumn.addConditionalFormat(ExcelScript.ConditionalFormatType.containsText).getTextComparison();
// Set the conditional format to provide a green fill.
textConditionFormat.getFormat().getFill().setColor("green");
// Apply the condition rule that the text begins with "Excel".
const textRule: ExcelScript.ConditionalTextComparisonRule = {
operator: ExcelScript.ConditionalTextOperator.beginsWith,
text: "Excel"
};
textConditionFormat.setRule(textRule);
}
Methods
get |
Returns a format object, encapsulating the conditional format's font, fill, borders, and other properties. |
get |
The rule of the conditional format. |
set |
The rule of the conditional format. |
Method Details
getFormat()
Returns a format object, encapsulating the conditional format's font, fill, borders, and other properties.
getFormat(): ConditionalRangeFormat;
Returns
getRule()
The rule of the conditional format.
getRule(): ConditionalTextComparisonRule;
Returns
setRule(rule)
The rule of the conditional format.
setRule(rule: ConditionalTextComparisonRule): void;
Parameters
Returns
void
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Scripts