@univerjs/sheets-conditional-formatting v0.5.4
Interface: IFRangeConditionalFormattingMixin
Defined in: sheets-conditional-formatting/src/facade/f-range.ts:37
Methods
addConditionalFormattingRule()
addConditionalFormattingRule(rule): FRange
Defined in: sheets-conditional-formatting/src/facade/f-range.ts:80
Add a new conditional format
Parameters
Parameter | Type |
---|---|
rule | IConditionFormattingRule |
Returns
Returns the current range instance for method chaining
Memberof
IFRangeConditionalFormattingMixin
createConditionalFormattingRule()
createConditionalFormattingRule(): FConditionalFormattingBuilder
Defined in: sheets-conditional-formatting/src/facade/f-range.ts:72
Creates a constructor for conditional formatting
Returns
{ConditionalFormatRuleBuilder}
Memberof
IFWorksheetConditionalFormattingMixin
Example
const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook?.getActiveSheet();
const rule = worksheet?.createConditionalFormattingRule()
.whenCellNotEmpty()
.setRanges([{ startRow: 0, endRow: 100, startColumn: 0, endColumn: 100 }])
.setItalic(true)
.setItalic(true)
.setBackground('red')
.setFontColor('green')
.build();
worksheet?.addConditionalFormattingRule(rule!);
deleteConditionalFormattingRule()
deleteConditionalFormattingRule(cfId): FRange
Defined in: sheets-conditional-formatting/src/facade/f-range.ts:95
Delete conditional format according to cfId
Parameters
Parameter | Type |
---|---|
cfId | string |
Returns
Returns the current range instance for method chaining
Memberof
IFRangeConditionalFormattingMixin
Example
const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook?.getActiveSheet();
const rules = worksheet?.getConditionalFormattingRules();
worksheet?.deleteConditionalFormattingRule(rules![0].cfId);
getConditionalFormattingRules()
getConditionalFormattingRules(): IConditionFormattingRule[]
Defined in: sheets-conditional-formatting/src/facade/f-range.ts:51
Gets all the conditional formatting for the current range
Returns
{IConditionFormattingRule[]}
Memberof
IFWorksheetConditionalFormattingMixin
Example
const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook?.getActiveSheet();
workbook?.setActiveRange(worksheet?.getRange(5, 5, 3, 3)!);
const rules = univerAPI.getActiveWorkbook()?.getActiveRange()?.getConditionalFormattingRules();
moveConditionalFormattingRule()
moveConditionalFormattingRule(
cfId,
toCfId,
type?): FRange
Defined in: sheets-conditional-formatting/src/facade/f-range.ts:114
Modify the priority of the conditional format
Parameters
Parameter | Type | Description |
---|---|---|
cfId | string | Rules that need to be moved |
toCfId | string | Target rule |
type ? | "before" | "after" | "self" | After the default move to the destination rule, if type = before moves to the front, the default value is after |
Returns
Returns the current range instance for method chaining
Memberof
FRangeConditionalFormattingMixin
Example
const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook?.getActiveSheet();
const rules = worksheet?.getConditionalFormattingRules()!;
const rule = rules[2];
const targetRule = rules[0];
worksheet?.moveConditionalFormattingRule(rule.cfId, targetRule.cfId, 'before');
setConditionalFormattingRule()
setConditionalFormattingRule(cfId, rule): FRange
Defined in: sheets-conditional-formatting/src/facade/f-range.ts:131
Set the conditional format according to cfId
Parameters
Parameter | Type |
---|---|
cfId | string |
rule | IConditionFormattingRule |
Returns
Returns the current range instance for method chaining
Memberof
IFRangeConditionalFormattingMixin
Example
const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook?.getActiveSheet();
const rules = worksheet?.getConditionalFormattingRules()!;
const rule = rules[0];
worksheet?.setConditionalFormattingRule(rule.cfId, { ...rule, ranges: [] });