@univerjs/sheets-conditional-formatting v0.5.4
Interface: IFWorksheetConditionalFormattingMixin
Defined in: sheets-conditional-formatting/src/facade/f-worksheet.ts:35
Methods
addConditionalFormattingRule()
addConditionalFormattingRule(rule): FWorksheet
Defined in: sheets-conditional-formatting/src/facade/f-worksheet.ts:109
Add a new conditional format
Parameters
Parameter | Type |
---|---|
rule | IConditionFormattingRule |
Returns
Returns the current worksheet instance for method chaining
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!);
createConditionalFormattingRule()
createConditionalFormattingRule(): FConditionalFormattingBuilder
Defined in: sheets-conditional-formatting/src/facade/f-worksheet.ts:67
Returns
Deprecated
use newConditionalFormattingRule instead. Creates a constructor for conditional formatting
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();
deleteConditionalFormattingRule()
deleteConditionalFormattingRule(cfId): FWorksheet
Defined in: sheets-conditional-formatting/src/facade/f-worksheet.ts:124
Delete conditional format according to cfId
Parameters
Parameter | Type |
---|---|
cfId | string |
Returns
Returns the current worksheet instance for method chaining
Memberof
IFWorksheetConditionalFormattingMixin
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-worksheet.ts:46
Gets all the conditional formatting for the current sheet
Returns
{IConditionFormattingRule[]}
Memberof
IFWorksheetConditionalFormattingMixin
Example
univerAPI.getActiveWorkbook()?.getActiveSheet().getConditionalFormattingRules();
moveConditionalFormattingRule()
moveConditionalFormattingRule(
cfId,
toCfId,
type?): FWorksheet
Defined in: sheets-conditional-formatting/src/facade/f-worksheet.ts:143
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 worksheet instance for method chaining
Memberof
FWorksheetConditionalFormattingMixin
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');
newConditionalFormattingRule()
newConditionalFormattingRule(): FConditionalFormattingBuilder
Defined in: sheets-conditional-formatting/src/facade/f-worksheet.ts:87
Creates a constructor for conditional formatting
Returns
Examples
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();
Memberof
IFWorksheetConditionalFormattingMixin
setConditionalFormattingRule()
setConditionalFormattingRule(cfId, rule): FWorksheet
Defined in: sheets-conditional-formatting/src/facade/f-worksheet.ts:160
Set the conditional format according to cfId
Parameters
Parameter | Type |
---|---|
cfId | string |
rule | IConditionFormattingRule |
Returns
Returns the current worksheet instance for method chaining
Memberof
IFWorksheetConditionalFormattingMixin
Example
const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook?.getActiveSheet();
const rules = worksheet?.getConditionalFormattingRules()!;
const rule = rules[0];
worksheet?.setConditionalFormattingRule(rule.cfId, { ...rule, ranges: [] });