ExcelScript.TopBottomConditionalFormat interface
Represents a top/bottom conditional format.
Remarks
Examples
/**
* This sample applies conditional formatting to the currently used range in the worksheet.
* The conditional formatting is a green fill for the top 10% of values.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the current worksheet.
let selectedSheet = workbook.getActiveWorksheet();
// Get the used range in the worksheet.
let range = selectedSheet.getUsedRange();
// Set the fill color to green for the top 10% of values in the range.
let conditionalFormat = range.addConditionalFormat(ExcelScript.ConditionalFormatType.topBottom)
conditionalFormat.getTopBottom().getFormat().getFill().setColor("green");
conditionalFormat.getTopBottom().setRule({
rank: 10, /* The percentage threshold. */
type: ExcelScript.ConditionalTopBottomCriterionType.topPercent /* The type of the top/bottom condition. */
});
}
Methods
get |
Returns a format object, encapsulating the conditional format's font, fill, borders, and other properties. |
get |
The criteria of the top/bottom conditional format. |
set |
The criteria of the top/bottom 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 criteria of the top/bottom conditional format.
getRule(): ConditionalTopBottomRule;
Returns
setRule(rule)
The criteria of the top/bottom conditional format.
setRule(rule: ConditionalTopBottomRule): 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