@univerjs/sheets-conditional-formatting 0.6.1 → 0.6.2-nightly.202503031606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1405 -317
- package/lib/es/index.js +975 -862
- package/lib/types/base/const.d.ts +1 -1
- package/lib/types/commands/commands/add-cf.command.d.ts +9 -0
- package/lib/types/commands/commands/clear-range-cf.command.d.ts +7 -0
- package/lib/types/commands/commands/clear-worksheet-cf.command.d.ts +6 -0
- package/lib/types/commands/commands/delete-cf.command.d.ts +7 -0
- package/lib/types/commands/commands/move-cf.command.d.ts +9 -0
- package/lib/types/commands/commands/set-cf.command.d.ts +9 -0
- package/lib/types/facade/f-conditional-formatting-builder.d.ts +1566 -0
- package/lib/types/facade/f-enum.d.ts +22 -0
- package/lib/types/facade/f-range.d.ts +27 -25
- package/lib/types/facade/f-worksheet.d.ts +24 -15
- package/lib/types/facade/index.d.ts +2 -1
- package/lib/types/index.d.ts +6 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
- package/LICENSE +0 -176
- package/lib/types/facade/conditional-formatting-builder.d.ts +0 -506
package/lib/es/facade.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var q = (u, e, t) => e in u ?
|
|
3
|
-
var
|
|
4
|
-
import { ColorKit as
|
|
5
|
-
import { CFRuleType as n, EMPTY_ICON_TYPE as
|
|
6
|
-
import { FRange as
|
|
7
|
-
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var q = (u, e, t) => e in u ? U(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
|
|
3
|
+
var T = (u, e, t) => q(u, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ColorKit as m, Tools as f, BooleanNumber as a, Rectangle as B, ColorBuilder as A } from "@univerjs/core";
|
|
5
|
+
import { iconMap as I, CFRuleType as n, EMPTY_ICON_TYPE as _, CFValueType as C, CFNumberOperator as s, CFTextOperator as g, CFSubRuleType as o, createCfId as d, ConditionalFormattingRuleModel as x, AddCfCommand as S, DeleteCfCommand as E, MoveCfCommand as k, SetCfCommand as F, ClearRangeCfCommand as M, ClearWorksheetCfCommand as O, CFTimePeriodOperator as D } from "@univerjs/sheets-conditional-formatting";
|
|
6
|
+
import { FRange as v, FWorkbook as R, FWorksheet as N } from "@univerjs/sheets/facade";
|
|
7
|
+
import { FEnum as V } from "@univerjs/core/facade";
|
|
8
|
+
class c {
|
|
8
9
|
constructor(e = {}) {
|
|
9
|
-
|
|
10
|
+
T(this, "_rule", {});
|
|
10
11
|
this._rule = e, this._ensureAttr(this._rule, ["rule"]);
|
|
11
12
|
}
|
|
12
13
|
get _ruleConfig() {
|
|
@@ -18,15 +19,15 @@ class d {
|
|
|
18
19
|
return {
|
|
19
20
|
type: e,
|
|
20
21
|
config: [
|
|
21
|
-
{ index: 0, color: new
|
|
22
|
-
{ index: 0, color: new
|
|
22
|
+
{ index: 0, color: new m("").toRgbString(), value: { type: C.min } },
|
|
23
|
+
{ index: 0, color: new m("green").toRgbString(), value: { type: C.max } }
|
|
23
24
|
]
|
|
24
25
|
};
|
|
25
26
|
case n.dataBar:
|
|
26
27
|
return {
|
|
27
28
|
type: e,
|
|
28
29
|
isShowValue: !0,
|
|
29
|
-
config: { min: { type: C.min }, max: { type: C.max }, positiveColor: new
|
|
30
|
+
config: { min: { type: C.min }, max: { type: C.max }, positiveColor: new m("green").toRgbString(), nativeColor: new m("").toRgbString(), isGradient: !1 }
|
|
30
31
|
};
|
|
31
32
|
case n.highlightCell:
|
|
32
33
|
return {
|
|
@@ -40,357 +41,829 @@ class d {
|
|
|
40
41
|
return {
|
|
41
42
|
type: e,
|
|
42
43
|
isShowValue: !0,
|
|
43
|
-
config: [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
iconType: f,
|
|
60
|
-
iconId: ""
|
|
61
|
-
}
|
|
62
|
-
]
|
|
44
|
+
config: [{
|
|
45
|
+
operator: s.greaterThanOrEqual,
|
|
46
|
+
value: { type: C.min },
|
|
47
|
+
iconType: _,
|
|
48
|
+
iconId: ""
|
|
49
|
+
}, {
|
|
50
|
+
operator: s.greaterThanOrEqual,
|
|
51
|
+
value: { type: C.percentile, value: 0.5 },
|
|
52
|
+
iconType: _,
|
|
53
|
+
iconId: ""
|
|
54
|
+
}, {
|
|
55
|
+
operator: s.lessThanOrEqual,
|
|
56
|
+
value: { type: C.max },
|
|
57
|
+
iconType: _,
|
|
58
|
+
iconId: ""
|
|
59
|
+
}]
|
|
63
60
|
};
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
// eslint-disable-next-line ts/no-explicit-any
|
|
67
64
|
_ensureAttr(e, t) {
|
|
68
|
-
return t.reduce((r,
|
|
65
|
+
return t.reduce((r, l) => (r[l] || (r[l] = {}), r[l]), e), e;
|
|
69
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Constructs a conditional format rule from the settings applied to the builder.
|
|
69
|
+
* @returns {IConditionFormattingRule} The conditional format rule.
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
73
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
74
|
+
*
|
|
75
|
+
* // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
|
|
76
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
77
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
78
|
+
* .whenCellEmpty()
|
|
79
|
+
* .setBackground('#FF0000')
|
|
80
|
+
* .setRanges([fRange.getRange()])
|
|
81
|
+
* .build();
|
|
82
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
70
85
|
build() {
|
|
71
86
|
var r;
|
|
72
|
-
this._rule.cfId || (this._rule.cfId =
|
|
87
|
+
this._rule.cfId || (this._rule.cfId = d()), this._rule.ranges || (this._rule.ranges = []), this._rule.stopIfTrue === void 0 && (this._rule.stopIfTrue = !1), (r = this._rule.rule) != null && r.type || (this._rule.rule.type = n.highlightCell, this._ensureAttr(this._rule, ["rule", "style"]));
|
|
73
88
|
const e = this._getDefaultConfig(this._rule.rule.type);
|
|
74
89
|
return { ...this._rule, rule: { ...e, ...this._rule.rule } };
|
|
75
90
|
}
|
|
76
91
|
/**
|
|
77
92
|
* Deep clone a current builder.
|
|
78
|
-
* @returns {
|
|
79
|
-
* @
|
|
93
|
+
* @returns {ConditionalFormatRuleBaseBuilder} A new builder with the same settings as the original.
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
97
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
98
|
+
*
|
|
99
|
+
* // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
|
|
100
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
101
|
+
* const builder = fWorksheet.newConditionalFormattingRule()
|
|
102
|
+
* .whenCellEmpty()
|
|
103
|
+
* .setBackground('#FF0000')
|
|
104
|
+
* .setRanges([fRange.getRange()]);
|
|
105
|
+
* fWorksheet.addConditionalFormattingRule(builder.build());
|
|
106
|
+
*
|
|
107
|
+
* // Copy the rule and change the background color to green for the range A1:B2.
|
|
108
|
+
* const newRange = fWorksheet.getRange('A1:B2');
|
|
109
|
+
* const newBuilder = builder.copy()
|
|
110
|
+
* .setBackground('#00FF00')
|
|
111
|
+
* .setRanges([newRange.getRange()]);
|
|
112
|
+
* fWorksheet.addConditionalFormattingRule(newBuilder.build());
|
|
113
|
+
* ```
|
|
80
114
|
*/
|
|
81
115
|
copy() {
|
|
82
|
-
|
|
116
|
+
const e = f.deepClone(this._rule);
|
|
117
|
+
return e.cfId && (e.cfId = d()), new c(e);
|
|
83
118
|
}
|
|
84
119
|
/**
|
|
85
|
-
* Gets the scope of the current conditional format
|
|
86
|
-
* @returns {
|
|
87
|
-
* @memberof ConditionalFormatRuleBuilder
|
|
120
|
+
* Gets the scope of the current conditional format.
|
|
121
|
+
* @returns {IRange[]} The ranges to which the conditional format applies.
|
|
88
122
|
*/
|
|
89
123
|
getRanges() {
|
|
90
124
|
return this._rule.ranges || [];
|
|
91
125
|
}
|
|
92
126
|
/**
|
|
93
|
-
* Get the icon set mapping dictionary
|
|
127
|
+
* Get the icon set mapping dictionary.
|
|
128
|
+
* @returns {Record<string, string[]>} The icon set mapping dictionary.
|
|
94
129
|
*/
|
|
95
130
|
getIconMap() {
|
|
96
|
-
return
|
|
131
|
+
return I;
|
|
97
132
|
}
|
|
98
133
|
/**
|
|
99
134
|
* Create a conditional format ID.
|
|
100
|
-
* @returns {
|
|
101
|
-
* @memberof ConditionalFormatRuleBuilder
|
|
135
|
+
* @returns {string} The conditional format ID.
|
|
102
136
|
*/
|
|
103
137
|
createCfId() {
|
|
104
|
-
return
|
|
138
|
+
return d();
|
|
105
139
|
}
|
|
106
140
|
/**
|
|
107
|
-
* Sets the scope for conditional formatting
|
|
108
|
-
* @param {IRange[]} ranges
|
|
109
|
-
* @returns {
|
|
110
|
-
* @
|
|
141
|
+
* Sets the scope for conditional formatting.
|
|
142
|
+
* @param {IRange[]} ranges - The ranges to which the conditional format applies.
|
|
143
|
+
* @returns {ConditionalFormatRuleBaseBuilder} This builder for chaining.
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
147
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
148
|
+
*
|
|
149
|
+
* // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
|
|
150
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
151
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
152
|
+
* .whenCellEmpty()
|
|
153
|
+
* .setBackground('#FF0000')
|
|
154
|
+
* .setRanges([fRange.getRange()])
|
|
155
|
+
* .build();
|
|
156
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
157
|
+
* ```
|
|
111
158
|
*/
|
|
112
159
|
setRanges(e) {
|
|
113
160
|
return this._rule.ranges = e, this;
|
|
114
161
|
}
|
|
115
162
|
}
|
|
116
|
-
class i extends
|
|
163
|
+
class i extends c {
|
|
117
164
|
constructor(e = {}) {
|
|
118
165
|
super(e), this._ensureAttr(this._rule, ["rule", "style"]);
|
|
119
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Deep clone a current builder.
|
|
169
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} A new builder with the same settings as the original.
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
173
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
174
|
+
*
|
|
175
|
+
* // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
|
|
176
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
177
|
+
* const builder = fWorksheet.newConditionalFormattingRule()
|
|
178
|
+
* .whenCellEmpty()
|
|
179
|
+
* .setBackground('#FF0000')
|
|
180
|
+
* .setRanges([fRange.getRange()]);
|
|
181
|
+
* fWorksheet.addConditionalFormattingRule(builder.build());
|
|
182
|
+
*
|
|
183
|
+
* // Copy the rule and change the background color to green for the range A1:B2.
|
|
184
|
+
* const newRange = fWorksheet.getRange('A1:B2');
|
|
185
|
+
* const newBuilder = builder.copy()
|
|
186
|
+
* .setBackground('#00FF00')
|
|
187
|
+
* .setRanges([newRange.getRange()]);
|
|
188
|
+
* fWorksheet.addConditionalFormattingRule(newBuilder.build());
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
120
191
|
copy() {
|
|
121
|
-
|
|
192
|
+
const e = f.deepClone(this._rule);
|
|
193
|
+
return e.cfId && (e.cfId = d()), new i(e);
|
|
122
194
|
}
|
|
123
195
|
/**
|
|
124
|
-
* Set average rule
|
|
125
|
-
* @param {IAverageHighlightCell['operator']} operator
|
|
126
|
-
* @
|
|
196
|
+
* Set average rule.
|
|
197
|
+
* @param {IAverageHighlightCell['operator']} operator - The operator to use for the average rule.
|
|
198
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
202
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
203
|
+
*
|
|
204
|
+
* // Create a conditional formatting rule that highlights cells with greater than average values in red for the range A1:D10.
|
|
205
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
206
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
207
|
+
* .setAverage(univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan)
|
|
208
|
+
* .setBackground('#FF0000')
|
|
209
|
+
* .setRanges([fRange.getRange()])
|
|
210
|
+
* .build();
|
|
211
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
212
|
+
* ```
|
|
127
213
|
*/
|
|
128
214
|
setAverage(e) {
|
|
129
215
|
const t = this._ruleConfig;
|
|
130
216
|
return t.type = n.highlightCell, t.subType = o.average, t.operator = e, this;
|
|
131
217
|
}
|
|
132
218
|
/**
|
|
133
|
-
* Set
|
|
134
|
-
* @
|
|
219
|
+
* Set unique values rule.
|
|
220
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
224
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
225
|
+
*
|
|
226
|
+
* // Create a conditional formatting rule that highlights cells with unique values in red for the range A1:D10.
|
|
227
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
228
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
229
|
+
* .setUniqueValues()
|
|
230
|
+
* .setBackground('#FF0000')
|
|
231
|
+
* .setRanges([fRange.getRange()])
|
|
232
|
+
* .build();
|
|
233
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
234
|
+
* ```
|
|
135
235
|
*/
|
|
136
236
|
setUniqueValues() {
|
|
137
237
|
const e = this._ruleConfig;
|
|
138
238
|
return e.type = n.highlightCell, e.subType = o.uniqueValues, this;
|
|
139
239
|
}
|
|
140
240
|
/**
|
|
141
|
-
* Set
|
|
142
|
-
* @
|
|
241
|
+
* Set duplicate values rule.
|
|
242
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
246
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
247
|
+
*
|
|
248
|
+
* // Create a conditional formatting rule that highlights cells with duplicate values in red for the range A1:D10.
|
|
249
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
250
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
251
|
+
* .setDuplicateValues()
|
|
252
|
+
* .setBackground('#FF0000')
|
|
253
|
+
* .setRanges([fRange.getRange()])
|
|
254
|
+
* .build();
|
|
255
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
256
|
+
* ```
|
|
143
257
|
*/
|
|
144
258
|
setDuplicateValues() {
|
|
145
259
|
const e = this._ruleConfig;
|
|
146
260
|
return e.type = n.highlightCell, e.subType = o.duplicateValues, this;
|
|
147
261
|
}
|
|
148
262
|
/**
|
|
149
|
-
* Set rank rule
|
|
150
|
-
* @param {{ isBottom: boolean, isPercent: boolean, value: number }} config
|
|
151
|
-
* @param config.isBottom
|
|
152
|
-
* @param config.isPercent
|
|
153
|
-
* @param config.value
|
|
154
|
-
* @
|
|
263
|
+
* Set rank rule.
|
|
264
|
+
* @param {{ isBottom: boolean, isPercent: boolean, value: number }} config - The rank rule settings.
|
|
265
|
+
* @param {boolean} config.isBottom - Whether to highlight the bottom rank.
|
|
266
|
+
* @param {boolean} config.isPercent - Whether to use a percentage rank.
|
|
267
|
+
* @param {number} config.value - The rank value.
|
|
268
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
272
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
273
|
+
*
|
|
274
|
+
* // Create a conditional formatting rule that highlights the bottom 10% of values in red for the range A1:D10.
|
|
275
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
276
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
277
|
+
* .setRank({ isBottom: true, isPercent: true, value: 10 })
|
|
278
|
+
* .setBackground('#FF0000')
|
|
279
|
+
* .setRanges([fRange.getRange()])
|
|
280
|
+
* .build();
|
|
281
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
282
|
+
* ```
|
|
155
283
|
*/
|
|
156
284
|
setRank(e) {
|
|
157
285
|
const t = this._ruleConfig;
|
|
158
286
|
return t.type = n.highlightCell, t.subType = o.rank, t.isBottom = e.isBottom, t.isPercent = e.isPercent, t.value = e.value, this;
|
|
159
287
|
}
|
|
160
288
|
/**
|
|
161
|
-
* Sets the background color
|
|
162
|
-
* @param {string} [color]
|
|
163
|
-
* @returns {
|
|
164
|
-
* @
|
|
289
|
+
* Sets the background color for the conditional format rule's format.
|
|
290
|
+
* @param {string} [color] - The background color to set. If not provided, the background color is removed.
|
|
291
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
295
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
296
|
+
*
|
|
297
|
+
* // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
|
|
298
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
299
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
300
|
+
* .whenCellEmpty()
|
|
301
|
+
* .setBackground('#FF0000')
|
|
302
|
+
* .setRanges([fRange.getRange()])
|
|
303
|
+
* .build();
|
|
304
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
305
|
+
* ```
|
|
165
306
|
*/
|
|
166
307
|
setBackground(e) {
|
|
167
308
|
var t;
|
|
168
309
|
if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
|
|
169
310
|
if (e) {
|
|
170
311
|
this._ensureAttr(this._ruleConfig, ["style", "bg"]);
|
|
171
|
-
const r = new
|
|
312
|
+
const r = new m(e);
|
|
172
313
|
this._ruleConfig.style.bg.rgb = r.toRgbString();
|
|
173
314
|
} else
|
|
174
315
|
delete this._ruleConfig.style.bg;
|
|
175
316
|
return this;
|
|
176
317
|
}
|
|
177
318
|
/**
|
|
178
|
-
*
|
|
179
|
-
* @param {boolean} isBold
|
|
180
|
-
* @returns {
|
|
181
|
-
* @
|
|
319
|
+
* Sets text bolding for the conditional format rule's format.
|
|
320
|
+
* @param {boolean} isBold - Whether to bold the text.
|
|
321
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
325
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
326
|
+
*
|
|
327
|
+
* // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:D10.
|
|
328
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
329
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
330
|
+
* .whenCellNotEmpty()
|
|
331
|
+
* .setBold(true)
|
|
332
|
+
* .setRanges([fRange.getRange()])
|
|
333
|
+
* .build();
|
|
334
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
335
|
+
* ```
|
|
182
336
|
*/
|
|
183
337
|
setBold(e) {
|
|
184
338
|
var t;
|
|
185
339
|
return ((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell && (this._ensureAttr(this._ruleConfig, ["style"]), this._ruleConfig.style.bl = e ? a.TRUE : a.FALSE), this;
|
|
186
340
|
}
|
|
187
341
|
/**
|
|
188
|
-
* Sets the font color
|
|
189
|
-
* @param {string} [color]
|
|
190
|
-
* @returns {
|
|
191
|
-
* @
|
|
342
|
+
* Sets the font color for the conditional format rule's format.
|
|
343
|
+
* @param {string} [color] - The font color to set. If not provided, the font color is removed.
|
|
344
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
348
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
349
|
+
*
|
|
350
|
+
* // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
|
|
351
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
352
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
353
|
+
* .whenCellNotEmpty()
|
|
354
|
+
* .setFontColor('#FF0000')
|
|
355
|
+
* .setRanges([fRange.getRange()])
|
|
356
|
+
* .build();
|
|
357
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
358
|
+
* ```
|
|
192
359
|
*/
|
|
193
360
|
setFontColor(e) {
|
|
194
361
|
var t;
|
|
195
362
|
if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
|
|
196
363
|
if (e) {
|
|
197
|
-
const r = new
|
|
364
|
+
const r = new m(e);
|
|
198
365
|
this._ensureAttr(this._ruleConfig, ["style", "cl"]), this._ruleConfig.style.cl.rgb = r.toRgbString();
|
|
199
366
|
} else
|
|
200
367
|
delete this._ruleConfig.style.cl;
|
|
201
368
|
return this;
|
|
202
369
|
}
|
|
203
370
|
/**
|
|
204
|
-
*
|
|
205
|
-
* @param {boolean} isItalic
|
|
206
|
-
* @returns {
|
|
207
|
-
* @
|
|
371
|
+
* Sets text italics for the conditional format rule's format.
|
|
372
|
+
* @param {boolean} isItalic - Whether to italicize the text.
|
|
373
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
374
|
+
* @example
|
|
375
|
+
* ```typescript
|
|
376
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
377
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
378
|
+
*
|
|
379
|
+
* // Create a conditional formatting rule that italicizes the text for cells with not empty content in the range A1:D10.
|
|
380
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
381
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
382
|
+
* .whenCellNotEmpty()
|
|
383
|
+
* .setItalic(true)
|
|
384
|
+
* .setRanges([fRange.getRange()])
|
|
385
|
+
* .build();
|
|
386
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
387
|
+
* ```
|
|
208
388
|
*/
|
|
209
389
|
setItalic(e) {
|
|
210
390
|
var t;
|
|
211
391
|
return ((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell && (this._ensureAttr(this._ruleConfig, ["style"]), this._ruleConfig.style.it = e ? a.TRUE : a.FALSE), this;
|
|
212
392
|
}
|
|
213
393
|
/**
|
|
214
|
-
*
|
|
215
|
-
* @param {boolean} isStrikethrough
|
|
216
|
-
* @returns {
|
|
217
|
-
* @
|
|
394
|
+
* Sets text strikethrough for the conditional format rule's format.
|
|
395
|
+
* @param {boolean} isStrikethrough - Whether is strikethrough the text.
|
|
396
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
397
|
+
* @example
|
|
398
|
+
* ```typescript
|
|
399
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
400
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
401
|
+
*
|
|
402
|
+
* // Create a conditional formatting rule that set text strikethrough for cells with not empty content in the range A1:D10.
|
|
403
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
404
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
405
|
+
* .whenCellNotEmpty()
|
|
406
|
+
* .setStrikethrough(true)
|
|
407
|
+
* .setRanges([fRange.getRange()])
|
|
408
|
+
* .build();
|
|
409
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
410
|
+
* ```
|
|
218
411
|
*/
|
|
219
412
|
setStrikethrough(e) {
|
|
220
413
|
var t;
|
|
221
414
|
return ((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell && (this._ensureAttr(this._ruleConfig, ["style", "st"]), this._ruleConfig.style.st.s = e ? a.TRUE : a.FALSE), this;
|
|
222
415
|
}
|
|
223
416
|
/**
|
|
224
|
-
*
|
|
225
|
-
* @param {boolean} isUnderline
|
|
226
|
-
* @returns {
|
|
227
|
-
* @
|
|
417
|
+
* Sets text underlining for the conditional format rule's format.
|
|
418
|
+
* @param {boolean} isUnderline - Whether to underline the text.
|
|
419
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
423
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
424
|
+
*
|
|
425
|
+
* // Create a conditional formatting rule that underlines the text for cells with not empty content in the range A1:D10.
|
|
426
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
427
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
428
|
+
* .whenCellNotEmpty()
|
|
429
|
+
* .setUnderline(true)
|
|
430
|
+
* .setRanges([fRange.getRange()])
|
|
431
|
+
* .build();
|
|
432
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
433
|
+
* ```
|
|
228
434
|
*/
|
|
229
435
|
setUnderline(e) {
|
|
230
436
|
var t;
|
|
231
437
|
return ((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell && (this._ensureAttr(this._ruleConfig, ["style", "ul"]), this._ruleConfig.style.ul.s = e ? a.TRUE : a.FALSE), this;
|
|
232
438
|
}
|
|
233
439
|
/**
|
|
234
|
-
* Sets the conditional
|
|
440
|
+
* Sets the conditional format rule to trigger when the cell is empty.
|
|
441
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
442
|
+
* @example
|
|
443
|
+
* ```typescript
|
|
444
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
445
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
446
|
+
*
|
|
447
|
+
* // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
|
|
448
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
449
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
450
|
+
* .whenCellEmpty()
|
|
451
|
+
* .setBackground('#FF0000')
|
|
452
|
+
* .setRanges([fRange.getRange()])
|
|
453
|
+
* .build();
|
|
454
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
455
|
+
* ```
|
|
235
456
|
*/
|
|
236
457
|
whenCellEmpty() {
|
|
237
458
|
const e = this._ruleConfig;
|
|
238
459
|
return e.type = n.highlightCell, e.subType = o.text, e.value = "", e.operator = g.equal, this;
|
|
239
460
|
}
|
|
240
461
|
/**
|
|
241
|
-
* Sets the conditional
|
|
242
|
-
* @returns {
|
|
243
|
-
* @
|
|
462
|
+
* Sets the conditional format rule to trigger when the cell is not empty.
|
|
463
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
464
|
+
* @example
|
|
465
|
+
* ```typescript
|
|
466
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
467
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
468
|
+
*
|
|
469
|
+
* // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
|
|
470
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
471
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
472
|
+
* .whenCellNotEmpty()
|
|
473
|
+
* .setFontColor('#FF0000')
|
|
474
|
+
* .setRanges([fRange.getRange()])
|
|
475
|
+
* .build();
|
|
476
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
477
|
+
* ```
|
|
244
478
|
*/
|
|
245
479
|
whenCellNotEmpty() {
|
|
246
480
|
const e = this._ruleConfig;
|
|
247
481
|
return e.type = n.highlightCell, e.subType = o.text, e.value = "", e.operator = g.notEqual, this;
|
|
248
482
|
}
|
|
249
483
|
/**
|
|
250
|
-
*
|
|
251
|
-
* @param {CFTimePeriodOperator} date
|
|
252
|
-
* @returns {
|
|
253
|
-
* @
|
|
484
|
+
* Sets the conditional format rule to trigger when a time period is met.
|
|
485
|
+
* @param {CFTimePeriodOperator} date - The time period to check for.
|
|
486
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
487
|
+
* @example
|
|
488
|
+
* ```typescript
|
|
489
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
490
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
491
|
+
*
|
|
492
|
+
* // Create a conditional formatting rule that highlights cells with dates in the last 7 days in red for the range A1:D10.
|
|
493
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
494
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
495
|
+
* .whenDate(univerAPI.Enum.ConditionFormatTimePeriodOperatorEnum.last7Days)
|
|
496
|
+
* .setBackground('#FF0000')
|
|
497
|
+
* .setRanges([fRange.getRange()])
|
|
498
|
+
* .build();
|
|
499
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
500
|
+
* ```
|
|
254
501
|
*/
|
|
255
502
|
whenDate(e) {
|
|
256
503
|
const t = this._ruleConfig;
|
|
257
504
|
return t.type = n.highlightCell, t.subType = o.timePeriod, t.operator = e, this;
|
|
258
505
|
}
|
|
259
506
|
/**
|
|
260
|
-
* Sets
|
|
261
|
-
* @param {string} formulaString
|
|
262
|
-
* @
|
|
507
|
+
* Sets the conditional format rule to trigger when that the given formula evaluates to `true`.
|
|
508
|
+
* @param {string} formulaString - A custom formula that evaluates to true if the input is valid. formulaString start with '='.
|
|
509
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
510
|
+
* @example
|
|
511
|
+
* ```typescript
|
|
512
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
513
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
514
|
+
*
|
|
515
|
+
* // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
|
|
516
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
517
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
518
|
+
* .whenFormulaSatisfied('=A1>10')
|
|
519
|
+
* .setBackground('#FF0000')
|
|
520
|
+
* .setRanges([fRange.getRange()])
|
|
521
|
+
* .build();
|
|
522
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
523
|
+
* ```
|
|
263
524
|
*/
|
|
264
525
|
whenFormulaSatisfied(e) {
|
|
265
526
|
const t = this._ruleConfig;
|
|
266
527
|
return t.type = n.highlightCell, t.subType = o.formula, t.value = e, this;
|
|
267
528
|
}
|
|
268
529
|
/**
|
|
269
|
-
* Sets the conditional
|
|
270
|
-
* @param {number} start
|
|
271
|
-
* @param {number} end
|
|
272
|
-
* @
|
|
530
|
+
* Sets the conditional format rule to trigger when a number falls between, or is either of, two specified values.
|
|
531
|
+
* @param {number} start - The lowest acceptable value.
|
|
532
|
+
* @param {number} end - The highest acceptable value.
|
|
533
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
534
|
+
* @example
|
|
535
|
+
* ```typescript
|
|
536
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
537
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
538
|
+
*
|
|
539
|
+
* // Create a conditional formatting rule that highlights cells with values between 10 and 20 in red for the range A1:D10.
|
|
540
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
541
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
542
|
+
* .whenNumberBetween(10, 20)
|
|
543
|
+
* .setBackground('#FF0000')
|
|
544
|
+
* .setRanges([fRange.getRange()])
|
|
545
|
+
* .build();
|
|
546
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
547
|
+
* ```
|
|
273
548
|
*/
|
|
274
549
|
whenNumberBetween(e, t) {
|
|
275
|
-
const r = Math.min(e, t),
|
|
276
|
-
return h.type = n.highlightCell, h.subType = o.number, h.value = [r,
|
|
550
|
+
const r = Math.min(e, t), l = Math.max(e, t), h = this._ruleConfig;
|
|
551
|
+
return h.type = n.highlightCell, h.subType = o.number, h.value = [r, l], h.operator = s.between, this;
|
|
277
552
|
}
|
|
278
553
|
/**
|
|
279
|
-
* Sets the conditional
|
|
280
|
-
* @param {number} value
|
|
281
|
-
* @
|
|
554
|
+
* Sets the conditional format rule to trigger when a number is equal to the given value.
|
|
555
|
+
* @param {number} value - The sole acceptable value.
|
|
556
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
557
|
+
* @example
|
|
558
|
+
* ```typescript
|
|
559
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
560
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
561
|
+
*
|
|
562
|
+
* // Create a conditional formatting rule that highlights cells with values equal to 10 in red for the range A1:D10.
|
|
563
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
564
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
565
|
+
* .whenNumberEqualTo(10)
|
|
566
|
+
* .setBackground('#FF0000')
|
|
567
|
+
* .setRanges([fRange.getRange()])
|
|
568
|
+
* .build();
|
|
569
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
570
|
+
* ```
|
|
282
571
|
*/
|
|
283
572
|
whenNumberEqualTo(e) {
|
|
284
573
|
const t = this._ruleConfig;
|
|
285
|
-
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator =
|
|
574
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.equal, this;
|
|
286
575
|
}
|
|
287
576
|
/**
|
|
288
|
-
* Sets the conditional
|
|
289
|
-
* @param {number} value
|
|
290
|
-
* @
|
|
577
|
+
* Sets the conditional format rule to trigger when a number is greater than the given value.
|
|
578
|
+
* @param {number} value - The highest unacceptable value.
|
|
579
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
580
|
+
* @example
|
|
581
|
+
* ```typescript
|
|
582
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
583
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
584
|
+
*
|
|
585
|
+
* // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
|
|
586
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
587
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
588
|
+
* .whenNumberGreaterThan(10)
|
|
589
|
+
* .setBackground('#FF0000')
|
|
590
|
+
* .setRanges([fRange.getRange()])
|
|
591
|
+
* .build();
|
|
592
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
593
|
+
* ```
|
|
291
594
|
*/
|
|
292
595
|
whenNumberGreaterThan(e) {
|
|
293
596
|
const t = this._ruleConfig;
|
|
294
|
-
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator =
|
|
597
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.greaterThan, this;
|
|
295
598
|
}
|
|
296
599
|
/**
|
|
297
|
-
* Sets
|
|
298
|
-
* @param {number} value
|
|
299
|
-
* @
|
|
600
|
+
* Sets the conditional format rule to trigger when a number is greater than or equal to the given value.
|
|
601
|
+
* @param {number} value - The lowest acceptable value.
|
|
602
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
603
|
+
* @example
|
|
604
|
+
* ```typescript
|
|
605
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
606
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
607
|
+
*
|
|
608
|
+
* // Create a conditional formatting rule that highlights cells with values greater than or equal to 10 in red for the range A1:D10.
|
|
609
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
610
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
611
|
+
* .whenNumberGreaterThanOrEqualTo(10)
|
|
612
|
+
* .setBackground('#FF0000')
|
|
613
|
+
* .setRanges([fRange.getRange()])
|
|
614
|
+
* .build();
|
|
615
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
616
|
+
* ```
|
|
300
617
|
*/
|
|
301
618
|
whenNumberGreaterThanOrEqualTo(e) {
|
|
302
619
|
const t = this._ruleConfig;
|
|
303
|
-
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator =
|
|
620
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.greaterThanOrEqual, this;
|
|
304
621
|
}
|
|
305
622
|
/**
|
|
306
|
-
* Sets
|
|
307
|
-
* @param {number} value
|
|
308
|
-
* @
|
|
623
|
+
* Sets the conditional conditional format rule to trigger when a number less than the given value.
|
|
624
|
+
* @param {number} value - The lowest unacceptable value.
|
|
625
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
626
|
+
* @example
|
|
627
|
+
* ```typescript
|
|
628
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
629
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
630
|
+
*
|
|
631
|
+
* // Create a conditional formatting rule that highlights cells with values less than 10 in red for the range A1:D10.
|
|
632
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
633
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
634
|
+
* .whenNumberLessThan(10)
|
|
635
|
+
* .setBackground('#FF0000')
|
|
636
|
+
* .setRanges([fRange.getRange()])
|
|
637
|
+
* .build();
|
|
638
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
639
|
+
* ```
|
|
309
640
|
*/
|
|
310
641
|
whenNumberLessThan(e) {
|
|
311
642
|
const t = this._ruleConfig;
|
|
312
|
-
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator =
|
|
643
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.lessThan, this;
|
|
313
644
|
}
|
|
314
645
|
/**
|
|
315
|
-
* Sets the conditional
|
|
316
|
-
* @param {number} value
|
|
317
|
-
* @
|
|
646
|
+
* Sets the conditional format rule to trigger when a number less than or equal to the given value.
|
|
647
|
+
* @param {number} value - The highest acceptable value.
|
|
648
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
649
|
+
* @example
|
|
650
|
+
* ```typescript
|
|
651
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
652
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
653
|
+
*
|
|
654
|
+
* // Create a conditional formatting rule that highlights cells with values less than or equal to 10 in red for the range A1:D10.
|
|
655
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
656
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
657
|
+
* .whenNumberLessThanOrEqualTo(10)
|
|
658
|
+
* .setBackground('#FF0000')
|
|
659
|
+
* .setRanges([fRange.getRange()])
|
|
660
|
+
* .build();
|
|
661
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
662
|
+
* ```
|
|
318
663
|
*/
|
|
319
664
|
whenNumberLessThanOrEqualTo(e) {
|
|
320
665
|
const t = this._ruleConfig;
|
|
321
|
-
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator =
|
|
666
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.lessThanOrEqual, this;
|
|
322
667
|
}
|
|
323
668
|
/**
|
|
324
|
-
* Sets
|
|
325
|
-
* @param {number} start
|
|
326
|
-
* @param {number} end
|
|
327
|
-
* @
|
|
669
|
+
* Sets the conditional format rule to trigger when a number does not fall between, and is neither of, two specified values.
|
|
670
|
+
* @param {number} start - The lowest unacceptable value.
|
|
671
|
+
* @param {number} end - The highest unacceptable value.
|
|
672
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
676
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
677
|
+
*
|
|
678
|
+
* // Create a conditional formatting rule that highlights cells with values not between 10 and 20 in red for the range A1:D10.
|
|
679
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
680
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
681
|
+
* .whenNumberNotBetween(10, 20)
|
|
682
|
+
* .setBackground('#FF0000')
|
|
683
|
+
* .setRanges([fRange.getRange()])
|
|
684
|
+
* .build();
|
|
685
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
686
|
+
* ```
|
|
328
687
|
*/
|
|
329
688
|
whenNumberNotBetween(e, t) {
|
|
330
|
-
const r = Math.min(e, t),
|
|
331
|
-
return h.type = n.highlightCell, h.subType = o.number, h.value = [r,
|
|
689
|
+
const r = Math.min(e, t), l = Math.max(e, t), h = this._ruleConfig;
|
|
690
|
+
return h.type = n.highlightCell, h.subType = o.number, h.value = [r, l], h.operator = s.notBetween, this;
|
|
332
691
|
}
|
|
333
692
|
/**
|
|
334
|
-
* Sets the conditional
|
|
335
|
-
* @param value
|
|
336
|
-
* @
|
|
693
|
+
* Sets the conditional format rule to trigger when a number is not equal to the given value.
|
|
694
|
+
* @param {number} value - The sole unacceptable value.
|
|
695
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
696
|
+
* @example
|
|
697
|
+
* ```typescript
|
|
698
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
699
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
700
|
+
*
|
|
701
|
+
* // Create a conditional formatting rule that highlights cells with values not equal to 10 in red for the range A1:D10.
|
|
702
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
703
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
704
|
+
* .whenNumberNotEqualTo(10)
|
|
705
|
+
* .setBackground('#FF0000')
|
|
706
|
+
* .setRanges([fRange.getRange()])
|
|
707
|
+
* .build();
|
|
708
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
709
|
+
* ```
|
|
337
710
|
*/
|
|
338
711
|
whenNumberNotEqualTo(e) {
|
|
339
712
|
const t = this._ruleConfig;
|
|
340
|
-
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator =
|
|
713
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.notEqual, this;
|
|
341
714
|
}
|
|
342
715
|
/**
|
|
343
|
-
* Sets the conditional
|
|
344
|
-
* @param {string} text
|
|
345
|
-
* @
|
|
716
|
+
* Sets the conditional format rule to trigger when that the input contains the given value.
|
|
717
|
+
* @param {string} text - The value that the input must contain.
|
|
718
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
719
|
+
* @example
|
|
720
|
+
* ```typescript
|
|
721
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
722
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
723
|
+
*
|
|
724
|
+
* // Create a conditional formatting rule that highlights cells with text containing 'apple' in red for the range A1:D10.
|
|
725
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
726
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
727
|
+
* .whenTextContains('apple')
|
|
728
|
+
* .setBackground('#FF0000')
|
|
729
|
+
* .setRanges([fRange.getRange()])
|
|
730
|
+
* .build();
|
|
731
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
732
|
+
* ```
|
|
346
733
|
*/
|
|
347
734
|
whenTextContains(e) {
|
|
348
735
|
const t = this._ruleConfig;
|
|
349
736
|
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.containsText, this;
|
|
350
737
|
}
|
|
351
738
|
/**
|
|
352
|
-
* Sets
|
|
353
|
-
* @param {string} text
|
|
354
|
-
* @
|
|
739
|
+
* Sets the conditional format rule to trigger when that the input does not contain the given value.
|
|
740
|
+
* @param {string} text - The value that the input must not contain.
|
|
741
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
742
|
+
* @example
|
|
743
|
+
* ```typescript
|
|
744
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
745
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
746
|
+
*
|
|
747
|
+
* // Create a conditional formatting rule that highlights cells with text not containing 'apple' in red for the range A1:D10.
|
|
748
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
749
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
750
|
+
* .whenTextDoesNotContain('apple')
|
|
751
|
+
* .setBackground('#FF0000')
|
|
752
|
+
* .setRanges([fRange.getRange()])
|
|
753
|
+
* .build();
|
|
754
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
755
|
+
* ```
|
|
355
756
|
*/
|
|
356
757
|
whenTextDoesNotContain(e) {
|
|
357
758
|
const t = this._ruleConfig;
|
|
358
759
|
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.notContainsText, this;
|
|
359
760
|
}
|
|
360
761
|
/**
|
|
361
|
-
* Sets
|
|
362
|
-
* @param {string} text
|
|
363
|
-
* @
|
|
762
|
+
* Sets the conditional format rule to trigger when that the input ends with the given value.
|
|
763
|
+
* @param {string} text - Text to compare against the end of the string.
|
|
764
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
765
|
+
* @example
|
|
766
|
+
* ```typescript
|
|
767
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
768
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
769
|
+
*
|
|
770
|
+
* // Create a conditional formatting rule that highlights cells with text ending with '.ai' in red for the range A1:D10.
|
|
771
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
772
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
773
|
+
* .whenTextEndsWith('.ai')
|
|
774
|
+
* .setBackground('#FF0000')
|
|
775
|
+
* .setRanges([fRange.getRange()])
|
|
776
|
+
* .build();
|
|
777
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
778
|
+
* ```
|
|
364
779
|
*/
|
|
365
780
|
whenTextEndsWith(e) {
|
|
366
781
|
const t = this._ruleConfig;
|
|
367
782
|
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.endsWith, this;
|
|
368
783
|
}
|
|
369
784
|
/**
|
|
370
|
-
* Sets the conditional
|
|
371
|
-
* @param {string} text
|
|
372
|
-
* @
|
|
785
|
+
* Sets the conditional format rule to trigger when that the input is equal to the given value.
|
|
786
|
+
* @param {string} text - The sole acceptable value.
|
|
787
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
788
|
+
* @example
|
|
789
|
+
* ```typescript
|
|
790
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
791
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
792
|
+
*
|
|
793
|
+
* // Create a conditional formatting rule that highlights cells with text equal to 'apple' in red for the range A1:D10.
|
|
794
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
795
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
796
|
+
* .whenTextEqualTo('apple')
|
|
797
|
+
* .setBackground('#FF0000')
|
|
798
|
+
* .setRanges([fRange.getRange()])
|
|
799
|
+
* .build();
|
|
800
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
801
|
+
* ```
|
|
373
802
|
*/
|
|
374
803
|
whenTextEqualTo(e) {
|
|
375
804
|
const t = this._ruleConfig;
|
|
376
805
|
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.equal, this;
|
|
377
806
|
}
|
|
378
807
|
/**
|
|
379
|
-
* Sets the conditional
|
|
380
|
-
* @param {string} text
|
|
381
|
-
* @
|
|
808
|
+
* Sets the conditional format rule to trigger when that the input starts with the given value.
|
|
809
|
+
* @param {string} text - Text to compare against the beginning of the string.
|
|
810
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
|
|
811
|
+
* @example
|
|
812
|
+
* ```typescript
|
|
813
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
814
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
815
|
+
*
|
|
816
|
+
* // Create a conditional formatting rule that highlights cells with text starting with 'https://' in red for the range A1:D10.
|
|
817
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
818
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
819
|
+
* .whenTextStartsWith('https://')
|
|
820
|
+
* .setBackground('#FF0000')
|
|
821
|
+
* .setRanges([fRange.getRange()])
|
|
822
|
+
* .build();
|
|
823
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
824
|
+
* ```
|
|
382
825
|
*/
|
|
383
826
|
whenTextStartsWith(e) {
|
|
384
827
|
const t = this._ruleConfig;
|
|
385
828
|
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.beginsWith, this;
|
|
386
829
|
}
|
|
387
830
|
}
|
|
388
|
-
class
|
|
831
|
+
class p extends c {
|
|
832
|
+
/**
|
|
833
|
+
* Deep clone a current builder.
|
|
834
|
+
* @returns {ConditionalFormatDataBarRuleBuilder} A new instance of the builder with the same settings as the original.
|
|
835
|
+
* @example
|
|
836
|
+
* ```typescript
|
|
837
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
838
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
839
|
+
*
|
|
840
|
+
* // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
|
|
841
|
+
* // positive values are green and negative values are red.
|
|
842
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
843
|
+
* const builder = fWorksheet.newConditionalFormattingRule()
|
|
844
|
+
* .setDataBar({
|
|
845
|
+
* min: { type: 'num', value: -100 },
|
|
846
|
+
* max: { type: 'num', value: 100 },
|
|
847
|
+
* positiveColor: '#00FF00',
|
|
848
|
+
* nativeColor: '#FF0000',
|
|
849
|
+
* isShowValue: true
|
|
850
|
+
* })
|
|
851
|
+
* .setRanges([fRange.getRange()]);
|
|
852
|
+
* fWorksheet.addConditionalFormattingRule(builder.build());
|
|
853
|
+
*
|
|
854
|
+
* // Copy the rule and apply it to a new range.
|
|
855
|
+
* const newRange = fWorksheet.getRange('F1:F10');
|
|
856
|
+
* const newBuilder = builder.copy()
|
|
857
|
+
* .setRanges([newRange.getRange()]);
|
|
858
|
+
* fWorksheet.addConditionalFormattingRule(newBuilder.build());
|
|
859
|
+
* ```
|
|
860
|
+
*/
|
|
389
861
|
copy() {
|
|
390
|
-
|
|
862
|
+
const e = f.deepClone(this._rule);
|
|
863
|
+
return e.cfId && (e.cfId = d()), new p(e);
|
|
391
864
|
}
|
|
392
865
|
/**
|
|
393
|
-
*
|
|
866
|
+
* Set data bar rule.
|
|
394
867
|
* @param {{
|
|
395
868
|
* min: IValueConfig;
|
|
396
869
|
* max: IValueConfig;
|
|
@@ -398,14 +871,34 @@ class w extends d {
|
|
|
398
871
|
* positiveColor: string;
|
|
399
872
|
* nativeColor: string;
|
|
400
873
|
* isShowValue?: boolean;
|
|
401
|
-
* }} config
|
|
402
|
-
* @param config.min
|
|
403
|
-
* @param config.max
|
|
404
|
-
* @param config.isGradient
|
|
405
|
-
* @param config.positiveColor
|
|
406
|
-
* @param config.nativeColor
|
|
407
|
-
* @param config.isShowValue
|
|
408
|
-
* @
|
|
874
|
+
* }} config - The data bar rule settings.
|
|
875
|
+
* @param {IValueConfig} config.min - The minimum value for the data bar.
|
|
876
|
+
* @param {IValueConfig} config.max - The maximum value for the data bar.
|
|
877
|
+
* @param {boolean} [config.isGradient] - Whether the data bar is gradient.
|
|
878
|
+
* @param {string} config.positiveColor - The color for positive values.
|
|
879
|
+
* @param {string} config.nativeColor - The color for negative values.
|
|
880
|
+
* @param {boolean} [config.isShowValue] - Whether to show the value in the cell.
|
|
881
|
+
* @returns {ConditionalFormatDataBarRuleBuilder} This builder for chaining.
|
|
882
|
+
* @example
|
|
883
|
+
* ```typescript
|
|
884
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
885
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
886
|
+
*
|
|
887
|
+
* // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
|
|
888
|
+
* // positive values are green and negative values are red.
|
|
889
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
890
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
891
|
+
* .setDataBar({
|
|
892
|
+
* min: { type: 'num', value: -100 },
|
|
893
|
+
* max: { type: 'num', value: 100 },
|
|
894
|
+
* positiveColor: '#00FF00',
|
|
895
|
+
* nativeColor: '#FF0000',
|
|
896
|
+
* isShowValue: true
|
|
897
|
+
* })
|
|
898
|
+
* .setRanges([fRange.getRange()])
|
|
899
|
+
* .build();
|
|
900
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
901
|
+
* ```
|
|
409
902
|
*/
|
|
410
903
|
setDataBar(e) {
|
|
411
904
|
const t = this._ruleConfig;
|
|
@@ -418,98 +911,334 @@ class w extends d {
|
|
|
418
911
|
}, this;
|
|
419
912
|
}
|
|
420
913
|
}
|
|
421
|
-
class
|
|
422
|
-
copy() {
|
|
423
|
-
return new p(_.deepClone(this._rule));
|
|
424
|
-
}
|
|
914
|
+
class y extends c {
|
|
425
915
|
/**
|
|
426
|
-
*
|
|
427
|
-
* @
|
|
428
|
-
* @
|
|
916
|
+
* Deep clone a current builder.
|
|
917
|
+
* @returns {ConditionalFormatColorScaleRuleBuilder} A new instance of the builder with the same settings as the original.
|
|
918
|
+
* @example
|
|
919
|
+
* ```typescript
|
|
920
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
921
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
922
|
+
*
|
|
923
|
+
* // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
|
|
924
|
+
* // The color scale is green for 0, yellow for 50, and red for 100.
|
|
925
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
926
|
+
* const builder = fWorksheet.newConditionalFormattingRule()
|
|
927
|
+
* .setColorScale([
|
|
928
|
+
* { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
|
|
929
|
+
* { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
|
|
930
|
+
* { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
|
|
931
|
+
* ])
|
|
932
|
+
* .setRanges([fRange.getRange()]);
|
|
933
|
+
* fWorksheet.addConditionalFormattingRule(builder.build());
|
|
934
|
+
*
|
|
935
|
+
* // Copy the rule and apply it to a new range.
|
|
936
|
+
* const newRange = fWorksheet.getRange('F1:F10');
|
|
937
|
+
* const newBuilder = builder.copy()
|
|
938
|
+
* .setRanges([newRange.getRange()]);
|
|
939
|
+
* fWorksheet.addConditionalFormattingRule(newBuilder.build());
|
|
940
|
+
* ```
|
|
941
|
+
*/
|
|
942
|
+
copy() {
|
|
943
|
+
const e = f.deepClone(this._rule);
|
|
944
|
+
return e.cfId && (e.cfId = d()), new y(e);
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Set color scale rule.
|
|
948
|
+
* @param {{ index: number; color: string; value: IValueConfig }[]} config - The color scale rule settings.
|
|
949
|
+
* @param {number} config.index - The index of the color scale configuration.
|
|
950
|
+
* @param {string} config.color - The color corresponding to the index of the color scale configuration.
|
|
951
|
+
* @param {IValueConfig} config.value - The condition value corresponding to the index of the color scale configuration.
|
|
952
|
+
* @returns {ConditionalFormatColorScaleRuleBuilder} This builder for chaining.
|
|
953
|
+
* @example
|
|
954
|
+
* ```typescript
|
|
955
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
956
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
957
|
+
*
|
|
958
|
+
* // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
|
|
959
|
+
* // The color scale is green for 0, yellow for 50, and red for 100.
|
|
960
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
961
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
962
|
+
* .setColorScale([
|
|
963
|
+
* { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
|
|
964
|
+
* { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
|
|
965
|
+
* { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
|
|
966
|
+
* ])
|
|
967
|
+
* .setRanges([fRange.getRange()])
|
|
968
|
+
* .build();
|
|
969
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
970
|
+
* ```
|
|
429
971
|
*/
|
|
430
972
|
setColorScale(e) {
|
|
431
973
|
const t = this._ruleConfig;
|
|
432
974
|
return t.type = n.colorScale, t.config = e, this;
|
|
433
975
|
}
|
|
434
976
|
}
|
|
435
|
-
class
|
|
436
|
-
copy() {
|
|
437
|
-
return new y(_.deepClone(this._rule));
|
|
438
|
-
}
|
|
977
|
+
class b extends c {
|
|
439
978
|
/**
|
|
979
|
+
* Deep clone a current builder.
|
|
980
|
+
* @returns {ConditionalFormatIconSetRuleBuilder} A new instance of the builder with the same settings as the original.
|
|
981
|
+
* @example
|
|
982
|
+
* ```typescript
|
|
983
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
984
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
440
985
|
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
986
|
+
* // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
|
|
987
|
+
* // The first arrow is green for values greater than 20.
|
|
988
|
+
* // The second arrow is yellow for values greater than 10.
|
|
989
|
+
* // The third arrow is red for values less than or equal to 10.
|
|
990
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
991
|
+
* const builder = fWorksheet.newConditionalFormattingRule()
|
|
992
|
+
* .setIconSet({
|
|
993
|
+
* iconConfigs: [
|
|
994
|
+
* { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },
|
|
995
|
+
* { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },
|
|
996
|
+
* { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }
|
|
997
|
+
* ],
|
|
998
|
+
* isShowValue: true,
|
|
999
|
+
* })
|
|
1000
|
+
* .setRanges([fRange.getRange()]);
|
|
1001
|
+
* fWorksheet.addConditionalFormattingRule(builder.build());
|
|
1002
|
+
*
|
|
1003
|
+
* // Copy the rule and apply it to a new range.
|
|
1004
|
+
* const newRange = fWorksheet.getRange('F1:F10');
|
|
1005
|
+
* const newBuilder = builder.copy()
|
|
1006
|
+
* .setRanges([newRange.getRange()]);
|
|
1007
|
+
* fWorksheet.addConditionalFormattingRule(newBuilder.build());
|
|
1008
|
+
* ```
|
|
1009
|
+
*/
|
|
1010
|
+
copy() {
|
|
1011
|
+
const e = f.deepClone(this._rule);
|
|
1012
|
+
return e.cfId && (e.cfId = d()), new b(e);
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Set up icon set conditional formatting rule.
|
|
1016
|
+
* @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config - The icon set conditional formatting rule settings.
|
|
1017
|
+
* @param {IIconSet['config']} config.iconConfigs - The icon configurations. iconId property is a string indexing of a group icons.
|
|
1018
|
+
* @param {boolean} config.isShowValue - Whether to show the value in the cell.
|
|
1019
|
+
* @returns {ConditionalFormatIconSetRuleBuilder} This builder for chaining.
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```typescript
|
|
1022
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1023
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1024
|
+
*
|
|
1025
|
+
* // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
|
|
1026
|
+
* // The first arrow is green for values greater than 20.
|
|
1027
|
+
* // The second arrow is yellow for values greater than 10.
|
|
1028
|
+
* // The third arrow is red for values less than or equal to 10.
|
|
1029
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1030
|
+
* const builder = fWorksheet.newConditionalFormattingRule();
|
|
1031
|
+
* console.log(builder.getIconMap()); // icons key-value map
|
|
1032
|
+
* const rule = builder.setIconSet({
|
|
1033
|
+
* iconConfigs: [
|
|
1034
|
+
* { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },
|
|
1035
|
+
* { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },
|
|
1036
|
+
* { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }
|
|
1037
|
+
* ],
|
|
1038
|
+
* isShowValue: true,
|
|
1039
|
+
* })
|
|
1040
|
+
* .setRanges([fRange.getRange()])
|
|
1041
|
+
* .build();
|
|
1042
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1043
|
+
* ```
|
|
446
1044
|
*/
|
|
447
1045
|
setIconSet(e) {
|
|
448
1046
|
const t = this._ruleConfig;
|
|
449
1047
|
return t.type = n.iconSet, t.config = e.iconConfigs, t.isShowValue = e.isShowValue, this;
|
|
450
1048
|
}
|
|
451
1049
|
}
|
|
452
|
-
class
|
|
1050
|
+
class w {
|
|
453
1051
|
constructor(e = {}) {
|
|
454
1052
|
this._initConfig = e;
|
|
455
1053
|
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Constructs a conditional format rule from the settings applied to the builder.
|
|
1056
|
+
* @returns {IConditionFormattingRule} The conditional format rule.
|
|
1057
|
+
* @example
|
|
1058
|
+
* ```typescript
|
|
1059
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1060
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1061
|
+
*
|
|
1062
|
+
* // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
|
|
1063
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1064
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1065
|
+
* .whenNumberGreaterThan(10)
|
|
1066
|
+
* .setBackground('#FF0000')
|
|
1067
|
+
* .setRanges([fRange.getRange()])
|
|
1068
|
+
* .build();
|
|
1069
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1070
|
+
* ```
|
|
1071
|
+
*/
|
|
456
1072
|
build() {
|
|
457
|
-
return new
|
|
1073
|
+
return new c(this._initConfig).build();
|
|
458
1074
|
}
|
|
459
1075
|
/**
|
|
460
|
-
* Set average rule
|
|
461
|
-
* @param {IAverageHighlightCell['operator']} operator
|
|
462
|
-
* @
|
|
1076
|
+
* Set average rule.
|
|
1077
|
+
* @param {IAverageHighlightCell['operator']} operator - The operator to use for the average rule.
|
|
1078
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1079
|
+
* @example
|
|
1080
|
+
* ```typescript
|
|
1081
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1082
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1083
|
+
*
|
|
1084
|
+
* // Create a conditional formatting rule that highlights cells with greater than average values in red for the range A1:D10.
|
|
1085
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1086
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1087
|
+
* .setAverage(univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan)
|
|
1088
|
+
* .setBackground('#FF0000')
|
|
1089
|
+
* .setRanges([fRange.getRange()])
|
|
1090
|
+
* .build();
|
|
1091
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1092
|
+
* ```
|
|
463
1093
|
*/
|
|
464
1094
|
setAverage(e) {
|
|
465
1095
|
return new i(this._initConfig).setAverage(e);
|
|
466
1096
|
}
|
|
467
1097
|
/**
|
|
468
|
-
* Set
|
|
469
|
-
* @
|
|
1098
|
+
* Set unique values rule.
|
|
1099
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```typescript
|
|
1102
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1103
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1104
|
+
*
|
|
1105
|
+
* // Create a conditional formatting rule that highlights cells with unique values in red for the range A1:D10.
|
|
1106
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1107
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1108
|
+
* .setUniqueValues()
|
|
1109
|
+
* .setBackground('#FF0000')
|
|
1110
|
+
* .setRanges([fRange.getRange()])
|
|
1111
|
+
* .build();
|
|
1112
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1113
|
+
* ```
|
|
470
1114
|
*/
|
|
471
1115
|
setUniqueValues() {
|
|
472
1116
|
return new i(this._initConfig).setUniqueValues();
|
|
473
1117
|
}
|
|
474
1118
|
/**
|
|
475
|
-
* Set
|
|
476
|
-
* @
|
|
1119
|
+
* Set duplicate values rule.
|
|
1120
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1121
|
+
* @example
|
|
1122
|
+
* ```typescript
|
|
1123
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1124
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1125
|
+
*
|
|
1126
|
+
* // Create a conditional formatting rule that highlights cells with duplicate values in red for the range A1:D10.
|
|
1127
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1128
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1129
|
+
* .setDuplicateValues()
|
|
1130
|
+
* .setBackground('#FF0000')
|
|
1131
|
+
* .setRanges([fRange.getRange()])
|
|
1132
|
+
* .build();
|
|
1133
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1134
|
+
* ```
|
|
477
1135
|
*/
|
|
478
1136
|
setDuplicateValues() {
|
|
479
1137
|
return new i(this._initConfig).setDuplicateValues();
|
|
480
1138
|
}
|
|
481
1139
|
/**
|
|
482
|
-
* Set rank rule
|
|
483
|
-
* @param {{ isBottom: boolean, isPercent: boolean, value: number }} config
|
|
484
|
-
* @param config.isBottom
|
|
485
|
-
* @param config.isPercent
|
|
486
|
-
* @param config.value
|
|
487
|
-
* @
|
|
1140
|
+
* Set rank rule.
|
|
1141
|
+
* @param {{ isBottom: boolean, isPercent: boolean, value: number }} config - The rank rule settings.
|
|
1142
|
+
* @param {boolean} config.isBottom - Whether to highlight the bottom rank.
|
|
1143
|
+
* @param {boolean} config.isPercent - Whether to use a percentage rank.
|
|
1144
|
+
* @param {number} config.value - The rank value.
|
|
1145
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1146
|
+
* @example
|
|
1147
|
+
* ```typescript
|
|
1148
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1149
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1150
|
+
*
|
|
1151
|
+
* // Create a conditional formatting rule that highlights the bottom 10% of values in red for the range A1:D10.
|
|
1152
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1153
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1154
|
+
* .setRank({ isBottom: true, isPercent: true, value: 10 })
|
|
1155
|
+
* .setBackground('#FF0000')
|
|
1156
|
+
* .setRanges([fRange.getRange()])
|
|
1157
|
+
* .build();
|
|
1158
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1159
|
+
* ```
|
|
488
1160
|
*/
|
|
489
1161
|
setRank(e) {
|
|
490
1162
|
return new i(this._initConfig).setRank(e);
|
|
491
1163
|
}
|
|
492
1164
|
/**
|
|
1165
|
+
* Get the icon set mapping dictionary.
|
|
1166
|
+
* @returns {Record<string, string[]>} The icon set mapping dictionary.
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```typescript
|
|
1169
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1170
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1171
|
+
* console.log(fWorksheet.newConditionalFormattingRule().getIconMap()); // icons key-value map
|
|
1172
|
+
* ```
|
|
1173
|
+
*/
|
|
1174
|
+
getIconMap() {
|
|
1175
|
+
return I;
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Set up icon set conditional formatting rule.
|
|
1179
|
+
* @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config - The icon set conditional formatting rule settings.
|
|
1180
|
+
* @param {IIconSet['config']} config.iconConfigs - The icon configurations. iconId property is a string indexing of a group icons.
|
|
1181
|
+
* @param {boolean} config.isShowValue - Whether to show the value in the cell.
|
|
1182
|
+
* @returns {ConditionalFormatIconSetRuleBuilder} The conditional format icon set rule builder.
|
|
1183
|
+
* @example
|
|
1184
|
+
* ```typescript
|
|
1185
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1186
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
493
1187
|
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
1188
|
+
* // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
|
|
1189
|
+
* // The first arrow is green for values greater than 20.
|
|
1190
|
+
* // The second arrow is yellow for values greater than 10.
|
|
1191
|
+
* // The third arrow is red for values less than or equal to 10.
|
|
1192
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1193
|
+
* const builder = fWorksheet.newConditionalFormattingRule();
|
|
1194
|
+
* console.log(builder.getIconMap()); // icons key-value map
|
|
1195
|
+
* const rule = builder.setIconSet({
|
|
1196
|
+
* iconConfigs: [
|
|
1197
|
+
* { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },
|
|
1198
|
+
* { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },
|
|
1199
|
+
* { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }
|
|
1200
|
+
* ],
|
|
1201
|
+
* isShowValue: true,
|
|
1202
|
+
* })
|
|
1203
|
+
* .setRanges([fRange.getRange()])
|
|
1204
|
+
* .build();
|
|
1205
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1206
|
+
* ```
|
|
499
1207
|
*/
|
|
500
1208
|
setIconSet(e) {
|
|
501
|
-
return new
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Set
|
|
505
|
-
* @param {{ index: number; color: string; value: IValueConfig }[]} config
|
|
506
|
-
* @
|
|
1209
|
+
return new b(this._initConfig).setIconSet(e);
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Set color scale rule.
|
|
1213
|
+
* @param {{ index: number; color: string; value: IValueConfig }[]} config - The color scale rule settings.
|
|
1214
|
+
* @param {number} config.index - The index of the color scale.
|
|
1215
|
+
* @param {string} config.color - The color for the color scale.
|
|
1216
|
+
* @param {IValueConfig} config.value - The value for the color scale.
|
|
1217
|
+
* @returns {ConditionalFormatColorScaleRuleBuilder} The conditional format color scale rule builder.
|
|
1218
|
+
* @example
|
|
1219
|
+
* ```typescript
|
|
1220
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1221
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1222
|
+
*
|
|
1223
|
+
* // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
|
|
1224
|
+
* // The color scale is green for 0, yellow for 50, and red for 100.
|
|
1225
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1226
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1227
|
+
* .setColorScale([
|
|
1228
|
+
* { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
|
|
1229
|
+
* { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
|
|
1230
|
+
* { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
|
|
1231
|
+
* ])
|
|
1232
|
+
* .setRanges([fRange.getRange()])
|
|
1233
|
+
* .build();
|
|
1234
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1235
|
+
* ```
|
|
507
1236
|
*/
|
|
508
1237
|
setColorScale(e) {
|
|
509
|
-
return new
|
|
1238
|
+
return new y(this._initConfig).setColorScale(e);
|
|
510
1239
|
}
|
|
511
1240
|
/**
|
|
512
|
-
* Set
|
|
1241
|
+
* Set data bar rule.
|
|
513
1242
|
* @param {{
|
|
514
1243
|
* min: IValueConfig;
|
|
515
1244
|
* max: IValueConfig;
|
|
@@ -517,225 +1246,560 @@ class m {
|
|
|
517
1246
|
* positiveColor: string;
|
|
518
1247
|
* nativeColor: string;
|
|
519
1248
|
* isShowValue?: boolean;
|
|
520
|
-
* }} config
|
|
521
|
-
* @param config.min
|
|
522
|
-
* @param config.max
|
|
523
|
-
* @param config.isGradient
|
|
524
|
-
* @param config.positiveColor
|
|
525
|
-
* @param config.nativeColor
|
|
526
|
-
* @param config.isShowValue
|
|
527
|
-
* @
|
|
1249
|
+
* }} config - The data bar rule settings.
|
|
1250
|
+
* @param {IValueConfig} config.min - The minimum value for the data bar.
|
|
1251
|
+
* @param {IValueConfig} config.max - The maximum value for the data bar.
|
|
1252
|
+
* @param {boolean} [config.isGradient] - Whether the data bar is gradient.
|
|
1253
|
+
* @param {string} config.positiveColor - The color for positive values.
|
|
1254
|
+
* @param {string} config.nativeColor - The color for negative values.
|
|
1255
|
+
* @param {boolean} [config.isShowValue] - Whether to show the value in the cell.
|
|
1256
|
+
* @returns {ConditionalFormatDataBarRuleBuilder} The conditional format data bar rule builder.
|
|
1257
|
+
* @example
|
|
1258
|
+
* ```typescript
|
|
1259
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1260
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1261
|
+
*
|
|
1262
|
+
* // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
|
|
1263
|
+
* // positive values are green and negative values are red.
|
|
1264
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1265
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1266
|
+
* .setDataBar({
|
|
1267
|
+
* min: { type: 'num', value: -100 },
|
|
1268
|
+
* max: { type: 'num', value: 100 },
|
|
1269
|
+
* positiveColor: '#00FF00',
|
|
1270
|
+
* nativeColor: '#FF0000',
|
|
1271
|
+
* isShowValue: true
|
|
1272
|
+
* })
|
|
1273
|
+
* .setRanges([fRange.getRange()])
|
|
1274
|
+
* .build();
|
|
1275
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1276
|
+
* ```
|
|
528
1277
|
*/
|
|
529
1278
|
setDataBar(e) {
|
|
530
|
-
return new
|
|
1279
|
+
return new p(this._initConfig).setDataBar(e);
|
|
531
1280
|
}
|
|
532
1281
|
/**
|
|
533
|
-
* Sets the background color
|
|
534
|
-
* @param {string} [color]
|
|
535
|
-
* @returns {
|
|
536
|
-
* @
|
|
1282
|
+
* Sets the background color for the conditional format rule's format.
|
|
1283
|
+
* @param {string} [color] - The background color to set. If not provided, the background color is removed.
|
|
1284
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```typescript
|
|
1287
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1288
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1289
|
+
*
|
|
1290
|
+
* // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
|
|
1291
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1292
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1293
|
+
* .whenCellEmpty()
|
|
1294
|
+
* .setBackground('#FF0000')
|
|
1295
|
+
* .setRanges([fRange.getRange()])
|
|
1296
|
+
* .build();
|
|
1297
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1298
|
+
* ```
|
|
537
1299
|
*/
|
|
538
1300
|
setBackground(e) {
|
|
539
1301
|
return new i(this._initConfig).setBackground(e);
|
|
540
1302
|
}
|
|
541
1303
|
/**
|
|
542
|
-
*
|
|
543
|
-
* @param {boolean} isBold
|
|
544
|
-
* @returns {
|
|
545
|
-
* @
|
|
1304
|
+
* Sets text bolding for the conditional format rule's format.
|
|
1305
|
+
* @param {boolean} isBold - Whether to bold the text.
|
|
1306
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1307
|
+
* @example
|
|
1308
|
+
* ```typescript
|
|
1309
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1310
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1311
|
+
*
|
|
1312
|
+
* // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:D10.
|
|
1313
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1314
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1315
|
+
* .whenCellNotEmpty()
|
|
1316
|
+
* .setBold(true)
|
|
1317
|
+
* .setRanges([fRange.getRange()])
|
|
1318
|
+
* .build();
|
|
1319
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1320
|
+
* ```
|
|
546
1321
|
*/
|
|
547
1322
|
setBold(e) {
|
|
548
1323
|
return new i(this._initConfig).setBold(e);
|
|
549
1324
|
}
|
|
550
1325
|
/**
|
|
551
|
-
* Sets the font color
|
|
552
|
-
* @param {string} [color]
|
|
553
|
-
* @returns {
|
|
554
|
-
* @
|
|
1326
|
+
* Sets the font color for the conditional format rule's format.
|
|
1327
|
+
* @param {string} [color] - The font color to set. If not provided, the font color is removed.
|
|
1328
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```typescript
|
|
1331
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1332
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1333
|
+
*
|
|
1334
|
+
* // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
|
|
1335
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1336
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1337
|
+
* .whenCellNotEmpty()
|
|
1338
|
+
* .setFontColor('#FF0000')
|
|
1339
|
+
* .setRanges([fRange.getRange()])
|
|
1340
|
+
* .build();
|
|
1341
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1342
|
+
* ```
|
|
555
1343
|
*/
|
|
556
1344
|
setFontColor(e) {
|
|
557
1345
|
return new i(this._initConfig).setFontColor(e);
|
|
558
1346
|
}
|
|
559
1347
|
/**
|
|
560
|
-
*
|
|
561
|
-
* @param {boolean} isItalic
|
|
562
|
-
* @returns {
|
|
563
|
-
* @
|
|
1348
|
+
* Sets text italics for the conditional format rule's format.
|
|
1349
|
+
* @param {boolean} isItalic - Whether to italicize the text.
|
|
1350
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1351
|
+
* @example
|
|
1352
|
+
* ```typescript
|
|
1353
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1354
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1355
|
+
*
|
|
1356
|
+
* // Create a conditional formatting rule that italicizes the text for cells with not empty content in the range A1:D10.
|
|
1357
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1358
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1359
|
+
* .whenCellNotEmpty()
|
|
1360
|
+
* .setItalic(true)
|
|
1361
|
+
* .setRanges([fRange.getRange()])
|
|
1362
|
+
* .build();
|
|
1363
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1364
|
+
* ```
|
|
564
1365
|
*/
|
|
565
1366
|
setItalic(e) {
|
|
566
1367
|
return new i(this._initConfig).setItalic(e);
|
|
567
1368
|
}
|
|
568
1369
|
/**
|
|
569
|
-
*
|
|
570
|
-
* @param {boolean} isStrikethrough
|
|
571
|
-
* @returns {
|
|
572
|
-
* @
|
|
1370
|
+
* Sets text strikethrough for the conditional format rule's format.
|
|
1371
|
+
* @param {boolean} isStrikethrough - Whether is strikethrough the text.
|
|
1372
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1373
|
+
* @example
|
|
1374
|
+
* ```typescript
|
|
1375
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1376
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1377
|
+
*
|
|
1378
|
+
* // Create a conditional formatting rule that set text strikethrough for cells with not empty content in the range A1:D10.
|
|
1379
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1380
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1381
|
+
* .whenCellNotEmpty()
|
|
1382
|
+
* .setStrikethrough(true)
|
|
1383
|
+
* .setRanges([fRange.getRange()])
|
|
1384
|
+
* .build();
|
|
1385
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1386
|
+
* ```
|
|
573
1387
|
*/
|
|
574
1388
|
setStrikethrough(e) {
|
|
575
1389
|
return new i(this._initConfig).setStrikethrough(e);
|
|
576
1390
|
}
|
|
577
1391
|
/**
|
|
578
|
-
*
|
|
579
|
-
* @param {boolean} isUnderline
|
|
580
|
-
* @returns {
|
|
581
|
-
* @
|
|
1392
|
+
* Sets text underlining for the conditional format rule's format.
|
|
1393
|
+
* @param {boolean} isUnderline - Whether to underline the text.
|
|
1394
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1395
|
+
* @example
|
|
1396
|
+
* ```typescript
|
|
1397
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1398
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1399
|
+
*
|
|
1400
|
+
* // Create a conditional formatting rule that underlines the text for cells with not empty content in the range A1:D10.
|
|
1401
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1402
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1403
|
+
* .whenCellNotEmpty()
|
|
1404
|
+
* .setUnderline(true)
|
|
1405
|
+
* .setRanges([fRange.getRange()])
|
|
1406
|
+
* .build();
|
|
1407
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1408
|
+
* ```
|
|
582
1409
|
*/
|
|
583
1410
|
setUnderline(e) {
|
|
584
1411
|
return new i(this._initConfig).setUnderline(e);
|
|
585
1412
|
}
|
|
586
1413
|
/**
|
|
587
|
-
* Sets the conditional
|
|
1414
|
+
* Sets the conditional format rule to trigger when the cell is empty.
|
|
1415
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1416
|
+
* @example
|
|
1417
|
+
* ```typescript
|
|
1418
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1419
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1420
|
+
*
|
|
1421
|
+
* // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
|
|
1422
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1423
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1424
|
+
* .whenCellEmpty()
|
|
1425
|
+
* .setBackground('#FF0000')
|
|
1426
|
+
* .setRanges([fRange.getRange()])
|
|
1427
|
+
* .build();
|
|
1428
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1429
|
+
* ```
|
|
588
1430
|
*/
|
|
589
1431
|
whenCellEmpty() {
|
|
590
1432
|
return new i(this._initConfig).whenCellEmpty();
|
|
591
1433
|
}
|
|
592
1434
|
/**
|
|
593
|
-
* Sets the conditional
|
|
594
|
-
* @returns {
|
|
595
|
-
* @
|
|
1435
|
+
* Sets the conditional format rule to trigger when the cell is not empty.
|
|
1436
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1437
|
+
* @example
|
|
1438
|
+
* ```typescript
|
|
1439
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1440
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1441
|
+
*
|
|
1442
|
+
* // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
|
|
1443
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1444
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1445
|
+
* .whenCellNotEmpty()
|
|
1446
|
+
* .setFontColor('#FF0000')
|
|
1447
|
+
* .setRanges([fRange.getRange()])
|
|
1448
|
+
* .build();
|
|
1449
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1450
|
+
* ```
|
|
596
1451
|
*/
|
|
597
1452
|
whenCellNotEmpty() {
|
|
598
1453
|
return new i(this._initConfig).whenCellNotEmpty();
|
|
599
1454
|
}
|
|
600
1455
|
/**
|
|
601
|
-
*
|
|
602
|
-
* @param {CFTimePeriodOperator} date
|
|
603
|
-
* @returns {
|
|
604
|
-
* @
|
|
1456
|
+
* Sets the conditional format rule to trigger when a time period is met.
|
|
1457
|
+
* @param {CFTimePeriodOperator} date - The time period to check for.
|
|
1458
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1459
|
+
* @example
|
|
1460
|
+
* ```typescript
|
|
1461
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1462
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1463
|
+
*
|
|
1464
|
+
* // Create a conditional formatting rule that highlights cells with dates in the last 7 days in red for the range A1:D10.
|
|
1465
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1466
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1467
|
+
* .whenDate(univerAPI.Enum.ConditionFormatTimePeriodOperatorEnum.last7Days)
|
|
1468
|
+
* .setBackground('#FF0000')
|
|
1469
|
+
* .setRanges([fRange.getRange()])
|
|
1470
|
+
* .build();
|
|
1471
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1472
|
+
* ```
|
|
605
1473
|
*/
|
|
606
1474
|
whenDate(e) {
|
|
607
1475
|
return new i(this._initConfig).whenDate(e);
|
|
608
1476
|
}
|
|
609
1477
|
/**
|
|
610
|
-
* Sets
|
|
611
|
-
* @param {string} formulaString
|
|
612
|
-
* @
|
|
1478
|
+
* Sets the conditional format rule to trigger when that the given formula evaluates to `true`.
|
|
1479
|
+
* @param {string} formulaString - A custom formula that evaluates to true if the input is valid. formulaString start with '='.
|
|
1480
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```typescript
|
|
1483
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1484
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1485
|
+
*
|
|
1486
|
+
* // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
|
|
1487
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1488
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1489
|
+
* .whenFormulaSatisfied('=A1>10')
|
|
1490
|
+
* .setBackground('#FF0000')
|
|
1491
|
+
* .setRanges([fRange.getRange()])
|
|
1492
|
+
* .build();
|
|
1493
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1494
|
+
* ```
|
|
613
1495
|
*/
|
|
614
1496
|
whenFormulaSatisfied(e) {
|
|
615
1497
|
return new i(this._initConfig).whenFormulaSatisfied(e);
|
|
616
1498
|
}
|
|
617
1499
|
/**
|
|
618
|
-
* Sets the conditional
|
|
619
|
-
* @param {number} start
|
|
620
|
-
* @param {number} end
|
|
621
|
-
* @
|
|
1500
|
+
* Sets the conditional format rule to trigger when a number falls between, or is either of, two specified values.
|
|
1501
|
+
* @param {number} start - The lowest acceptable value.
|
|
1502
|
+
* @param {number} end - The highest acceptable value.
|
|
1503
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1504
|
+
* @example
|
|
1505
|
+
* ```typescript
|
|
1506
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1507
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1508
|
+
*
|
|
1509
|
+
* // Create a conditional formatting rule that highlights cells with values between 10 and 20 in red for the range A1:D10.
|
|
1510
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1511
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1512
|
+
* .whenNumberBetween(10, 20)
|
|
1513
|
+
* .setBackground('#FF0000')
|
|
1514
|
+
* .setRanges([fRange.getRange()])
|
|
1515
|
+
* .build();
|
|
1516
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1517
|
+
* ```
|
|
622
1518
|
*/
|
|
623
1519
|
whenNumberBetween(e, t) {
|
|
624
1520
|
return new i(this._initConfig).whenNumberBetween(e, t);
|
|
625
1521
|
}
|
|
626
1522
|
/**
|
|
627
|
-
* Sets the conditional
|
|
628
|
-
* @param {number} value
|
|
629
|
-
* @
|
|
1523
|
+
* Sets the conditional format rule to trigger when a number is equal to the given value.
|
|
1524
|
+
* @param {number} value - The sole acceptable value.
|
|
1525
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1526
|
+
* @example
|
|
1527
|
+
* ```typescript
|
|
1528
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1529
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1530
|
+
*
|
|
1531
|
+
* // Create a conditional formatting rule that highlights cells with values equal to 10 in red for the range A1:D10.
|
|
1532
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1533
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1534
|
+
* .whenNumberEqualTo(10)
|
|
1535
|
+
* .setBackground('#FF0000')
|
|
1536
|
+
* .setRanges([fRange.getRange()])
|
|
1537
|
+
* .build();
|
|
1538
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1539
|
+
* ```
|
|
630
1540
|
*/
|
|
631
1541
|
whenNumberEqualTo(e) {
|
|
632
1542
|
return new i(this._initConfig).whenNumberEqualTo(e);
|
|
633
1543
|
}
|
|
634
1544
|
/**
|
|
635
|
-
* Sets the conditional
|
|
636
|
-
* @param {number} value
|
|
637
|
-
* @
|
|
1545
|
+
* Sets the conditional format rule to trigger when a number is greater than the given value.
|
|
1546
|
+
* @param {number} value - The highest unacceptable value.
|
|
1547
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1548
|
+
* @example
|
|
1549
|
+
* ```typescript
|
|
1550
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1551
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1552
|
+
*
|
|
1553
|
+
* // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
|
|
1554
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1555
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1556
|
+
* .whenNumberGreaterThan(10)
|
|
1557
|
+
* .setBackground('#FF0000')
|
|
1558
|
+
* .setRanges([fRange.getRange()])
|
|
1559
|
+
* .build();
|
|
1560
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1561
|
+
* ```
|
|
638
1562
|
*/
|
|
639
1563
|
whenNumberGreaterThan(e) {
|
|
640
1564
|
return new i(this._initConfig).whenNumberGreaterThan(e);
|
|
641
1565
|
}
|
|
642
1566
|
/**
|
|
643
|
-
* Sets
|
|
644
|
-
* @param {number} value
|
|
645
|
-
* @
|
|
1567
|
+
* Sets the conditional format rule to trigger when a number is greater than or equal to the given value.
|
|
1568
|
+
* @param {number} value - The lowest acceptable value.
|
|
1569
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1570
|
+
* @example
|
|
1571
|
+
* ```typescript
|
|
1572
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1573
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1574
|
+
*
|
|
1575
|
+
* // Create a conditional formatting rule that highlights cells with values greater than or equal to 10 in red for the range A1:D10.
|
|
1576
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1577
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1578
|
+
* .whenNumberGreaterThanOrEqualTo(10)
|
|
1579
|
+
* .setBackground('#FF0000')
|
|
1580
|
+
* .setRanges([fRange.getRange()])
|
|
1581
|
+
* .build();
|
|
1582
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1583
|
+
* ```
|
|
646
1584
|
*/
|
|
647
1585
|
whenNumberGreaterThanOrEqualTo(e) {
|
|
648
1586
|
return new i(this._initConfig).whenNumberGreaterThanOrEqualTo(e);
|
|
649
1587
|
}
|
|
650
1588
|
/**
|
|
651
|
-
* Sets
|
|
652
|
-
* @param {number} value
|
|
653
|
-
* @
|
|
1589
|
+
* Sets the conditional conditional format rule to trigger when a number less than the given value.
|
|
1590
|
+
* @param {number} value - The lowest unacceptable value.
|
|
1591
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```typescript
|
|
1594
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1595
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1596
|
+
*
|
|
1597
|
+
* // Create a conditional formatting rule that highlights cells with values less than 10 in red for the range A1:D10.
|
|
1598
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1599
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1600
|
+
* .whenNumberLessThan(10)
|
|
1601
|
+
* .setBackground('#FF0000')
|
|
1602
|
+
* .setRanges([fRange.getRange()])
|
|
1603
|
+
* .build();
|
|
1604
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1605
|
+
* ```
|
|
654
1606
|
*/
|
|
655
1607
|
whenNumberLessThan(e) {
|
|
656
1608
|
return new i(this._initConfig).whenNumberLessThan(e);
|
|
657
1609
|
}
|
|
658
1610
|
/**
|
|
659
|
-
* Sets the conditional
|
|
660
|
-
* @param {number} value
|
|
661
|
-
* @
|
|
1611
|
+
* Sets the conditional format rule to trigger when a number less than or equal to the given value.
|
|
1612
|
+
* @param {number} value - The highest acceptable value.
|
|
1613
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1614
|
+
* @example
|
|
1615
|
+
* ```typescript
|
|
1616
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1617
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1618
|
+
*
|
|
1619
|
+
* // Create a conditional formatting rule that highlights cells with values less than or equal to 10 in red for the range A1:D10.
|
|
1620
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1621
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1622
|
+
* .whenNumberLessThanOrEqualTo(10)
|
|
1623
|
+
* .setBackground('#FF0000')
|
|
1624
|
+
* .setRanges([fRange.getRange()])
|
|
1625
|
+
* .build();
|
|
1626
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1627
|
+
* ```
|
|
662
1628
|
*/
|
|
663
1629
|
whenNumberLessThanOrEqualTo(e) {
|
|
664
1630
|
return new i(this._initConfig).whenNumberLessThanOrEqualTo(e);
|
|
665
1631
|
}
|
|
666
1632
|
/**
|
|
667
|
-
* Sets
|
|
668
|
-
* @param {number} start
|
|
669
|
-
* @param {number} end
|
|
670
|
-
* @
|
|
1633
|
+
* Sets the conditional format rule to trigger when a number does not fall between, and is neither of, two specified values.
|
|
1634
|
+
* @param {number} start - The lowest unacceptable value.
|
|
1635
|
+
* @param {number} end - The highest unacceptable value.
|
|
1636
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1637
|
+
* @example
|
|
1638
|
+
* ```typescript
|
|
1639
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1640
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1641
|
+
*
|
|
1642
|
+
* // Create a conditional formatting rule that highlights cells with values not between 10 and 20 in red for the range A1:D10.
|
|
1643
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1644
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1645
|
+
* .whenNumberNotBetween(10, 20)
|
|
1646
|
+
* .setBackground('#FF0000')
|
|
1647
|
+
* .setRanges([fRange.getRange()])
|
|
1648
|
+
* .build();
|
|
1649
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1650
|
+
* ```
|
|
671
1651
|
*/
|
|
672
1652
|
whenNumberNotBetween(e, t) {
|
|
673
1653
|
return new i(this._initConfig).whenNumberNotBetween(e, t);
|
|
674
1654
|
}
|
|
675
1655
|
/**
|
|
676
|
-
* Sets the conditional
|
|
677
|
-
* @param value
|
|
678
|
-
* @
|
|
1656
|
+
* Sets the conditional format rule to trigger when a number is not equal to the given value.
|
|
1657
|
+
* @param {number} value - The sole unacceptable value.
|
|
1658
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1659
|
+
* @example
|
|
1660
|
+
* ```typescript
|
|
1661
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1662
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1663
|
+
*
|
|
1664
|
+
* // Create a conditional formatting rule that highlights cells with values not equal to 10 in red for the range A1:D10.
|
|
1665
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1666
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1667
|
+
* .whenNumberNotEqualTo(10)
|
|
1668
|
+
* .setBackground('#FF0000')
|
|
1669
|
+
* .setRanges([fRange.getRange()])
|
|
1670
|
+
* .build();
|
|
1671
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1672
|
+
* ```
|
|
679
1673
|
*/
|
|
680
1674
|
whenNumberNotEqualTo(e) {
|
|
681
1675
|
return new i(this._initConfig).whenNumberNotEqualTo(e);
|
|
682
1676
|
}
|
|
683
1677
|
/**
|
|
684
|
-
* Sets the conditional
|
|
685
|
-
* @param {string} text
|
|
686
|
-
* @
|
|
1678
|
+
* Sets the conditional format rule to trigger when that the input contains the given value.
|
|
1679
|
+
* @param {string} text - The value that the input must contain.
|
|
1680
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1681
|
+
* @example
|
|
1682
|
+
* ```typescript
|
|
1683
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1684
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1685
|
+
*
|
|
1686
|
+
* // Create a conditional formatting rule that highlights cells with text containing 'apple' in red for the range A1:D10.
|
|
1687
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1688
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1689
|
+
* .whenTextContains('apple')
|
|
1690
|
+
* .setBackground('#FF0000')
|
|
1691
|
+
* .setRanges([fRange.getRange()])
|
|
1692
|
+
* .build();
|
|
1693
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1694
|
+
* ```
|
|
687
1695
|
*/
|
|
688
1696
|
whenTextContains(e) {
|
|
689
1697
|
return new i(this._initConfig).whenTextContains(e);
|
|
690
1698
|
}
|
|
691
1699
|
/**
|
|
692
|
-
* Sets
|
|
693
|
-
* @param {string} text
|
|
694
|
-
* @
|
|
1700
|
+
* Sets the conditional format rule to trigger when that the input does not contain the given value.
|
|
1701
|
+
* @param {string} text - The value that the input must not contain.
|
|
1702
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1703
|
+
* @example
|
|
1704
|
+
* ```typescript
|
|
1705
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1706
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1707
|
+
*
|
|
1708
|
+
* // Create a conditional formatting rule that highlights cells with text not containing 'apple' in red for the range A1:D10.
|
|
1709
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1710
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1711
|
+
* .whenTextDoesNotContain('apple')
|
|
1712
|
+
* .setBackground('#FF0000')
|
|
1713
|
+
* .setRanges([fRange.getRange()])
|
|
1714
|
+
* .build();
|
|
1715
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1716
|
+
* ```
|
|
695
1717
|
*/
|
|
696
1718
|
whenTextDoesNotContain(e) {
|
|
697
1719
|
return new i(this._initConfig).whenTextDoesNotContain(e);
|
|
698
1720
|
}
|
|
699
1721
|
/**
|
|
700
|
-
* Sets
|
|
701
|
-
* @param {string} text
|
|
702
|
-
* @
|
|
1722
|
+
* Sets the conditional format rule to trigger when that the input ends with the given value.
|
|
1723
|
+
* @param {string} text - Text to compare against the end of the string.
|
|
1724
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1725
|
+
* @example
|
|
1726
|
+
* ```typescript
|
|
1727
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1728
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1729
|
+
*
|
|
1730
|
+
* // Create a conditional formatting rule that highlights cells with text ending with '.ai' in red for the range A1:D10.
|
|
1731
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1732
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1733
|
+
* .whenTextEndsWith('.ai')
|
|
1734
|
+
* .setBackground('#FF0000')
|
|
1735
|
+
* .setRanges([fRange.getRange()])
|
|
1736
|
+
* .build();
|
|
1737
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1738
|
+
* ```
|
|
703
1739
|
*/
|
|
704
1740
|
whenTextEndsWith(e) {
|
|
705
1741
|
return new i(this._initConfig).whenTextEndsWith(e);
|
|
706
1742
|
}
|
|
707
1743
|
/**
|
|
708
|
-
* Sets the conditional
|
|
709
|
-
* @param {string} text
|
|
710
|
-
* @
|
|
1744
|
+
* Sets the conditional format rule to trigger when that the input is equal to the given value.
|
|
1745
|
+
* @param {string} text - The sole acceptable value.
|
|
1746
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1747
|
+
* @example
|
|
1748
|
+
* ```typescript
|
|
1749
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1750
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1751
|
+
*
|
|
1752
|
+
* // Create a conditional formatting rule that highlights cells with text equal to 'apple' in red for the range A1:D10.
|
|
1753
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1754
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1755
|
+
* .whenTextEqualTo('apple')
|
|
1756
|
+
* .setBackground('#FF0000')
|
|
1757
|
+
* .setRanges([fRange.getRange()])
|
|
1758
|
+
* .build();
|
|
1759
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1760
|
+
* ```
|
|
711
1761
|
*/
|
|
712
1762
|
whenTextEqualTo(e) {
|
|
713
1763
|
return new i(this._initConfig).whenTextEqualTo(e);
|
|
714
1764
|
}
|
|
715
1765
|
/**
|
|
716
|
-
* Sets the conditional
|
|
717
|
-
* @param {string} text
|
|
718
|
-
* @
|
|
1766
|
+
* Sets the conditional format rule to trigger when that the input starts with the given value.
|
|
1767
|
+
* @param {string} text - Text to compare against the beginning of the string.
|
|
1768
|
+
* @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
|
|
1769
|
+
* @example
|
|
1770
|
+
* ```typescript
|
|
1771
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1772
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1773
|
+
*
|
|
1774
|
+
* // Create a conditional formatting rule that highlights cells with text starting with 'https://' in red for the range A1:D10.
|
|
1775
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
1776
|
+
* const rule = fWorksheet.newConditionalFormattingRule()
|
|
1777
|
+
* .whenTextStartsWith('https://')
|
|
1778
|
+
* .setBackground('#FF0000')
|
|
1779
|
+
* .setRanges([fRange.getRange()])
|
|
1780
|
+
* .build();
|
|
1781
|
+
* fWorksheet.addConditionalFormattingRule(rule);
|
|
1782
|
+
* ```
|
|
719
1783
|
*/
|
|
720
1784
|
whenTextStartsWith(e) {
|
|
721
1785
|
return new i(this._initConfig).whenTextStartsWith(e);
|
|
722
1786
|
}
|
|
723
1787
|
}
|
|
724
|
-
class
|
|
1788
|
+
class W extends v {
|
|
725
1789
|
_getConditionalFormattingRuleModel() {
|
|
726
1790
|
return this._injector.get(x);
|
|
727
1791
|
}
|
|
728
1792
|
getConditionalFormattingRules() {
|
|
729
|
-
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((t) => t.ranges.some((r) =>
|
|
1793
|
+
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((t) => t.ranges.some((r) => B.intersects(r, this._range)));
|
|
730
1794
|
}
|
|
731
1795
|
createConditionalFormattingRule() {
|
|
732
|
-
return new
|
|
1796
|
+
return new w({ ranges: [this._range] });
|
|
733
1797
|
}
|
|
734
1798
|
addConditionalFormattingRule(e) {
|
|
735
1799
|
const t = {
|
|
736
|
-
rule: e,
|
|
737
1800
|
unitId: this._workbook.getUnitId(),
|
|
738
|
-
subUnitId: this._worksheet.getSheetId()
|
|
1801
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1802
|
+
rule: e
|
|
739
1803
|
};
|
|
740
1804
|
return this._commandService.syncExecuteCommand(S.id, t), this;
|
|
741
1805
|
}
|
|
@@ -745,16 +1809,16 @@ class A extends k {
|
|
|
745
1809
|
subUnitId: this._worksheet.getSheetId(),
|
|
746
1810
|
cfId: e
|
|
747
1811
|
};
|
|
748
|
-
return this._commandService.syncExecuteCommand(
|
|
1812
|
+
return this._commandService.syncExecuteCommand(E.id, t), this;
|
|
749
1813
|
}
|
|
750
1814
|
moveConditionalFormattingRule(e, t, r = "after") {
|
|
751
|
-
const
|
|
1815
|
+
const l = {
|
|
752
1816
|
unitId: this._workbook.getUnitId(),
|
|
753
1817
|
subUnitId: this._worksheet.getSheetId(),
|
|
754
1818
|
start: { id: e, type: "self" },
|
|
755
1819
|
end: { id: t, type: r }
|
|
756
1820
|
};
|
|
757
|
-
return this._commandService.syncExecuteCommand(
|
|
1821
|
+
return this._commandService.syncExecuteCommand(k.id, l), this;
|
|
758
1822
|
}
|
|
759
1823
|
setConditionalFormattingRule(e, t) {
|
|
760
1824
|
const r = {
|
|
@@ -763,17 +1827,25 @@ class A extends k {
|
|
|
763
1827
|
rule: t,
|
|
764
1828
|
cfId: e
|
|
765
1829
|
};
|
|
766
|
-
return this._commandService.syncExecuteCommand(
|
|
1830
|
+
return this._commandService.syncExecuteCommand(F.id, r), this;
|
|
1831
|
+
}
|
|
1832
|
+
clearConditionalFormatRules() {
|
|
1833
|
+
const e = {
|
|
1834
|
+
unitId: this._workbook.getUnitId(),
|
|
1835
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1836
|
+
ranges: [this._range]
|
|
1837
|
+
};
|
|
1838
|
+
return this._commandService.syncExecuteCommand(M.id, e), this;
|
|
767
1839
|
}
|
|
768
1840
|
}
|
|
769
|
-
|
|
770
|
-
class
|
|
1841
|
+
v.extend(W);
|
|
1842
|
+
class L extends R {
|
|
771
1843
|
newColor() {
|
|
772
|
-
return new
|
|
1844
|
+
return new A();
|
|
773
1845
|
}
|
|
774
1846
|
}
|
|
775
|
-
|
|
776
|
-
class
|
|
1847
|
+
R.extend(L);
|
|
1848
|
+
class G extends N {
|
|
777
1849
|
_getConditionalFormattingRuleModel() {
|
|
778
1850
|
return this._injector.get(x);
|
|
779
1851
|
}
|
|
@@ -781,16 +1853,16 @@ class V extends R {
|
|
|
781
1853
|
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
|
|
782
1854
|
}
|
|
783
1855
|
createConditionalFormattingRule() {
|
|
784
|
-
return new
|
|
1856
|
+
return new w();
|
|
785
1857
|
}
|
|
786
1858
|
newConditionalFormattingRule() {
|
|
787
|
-
return new
|
|
1859
|
+
return new w();
|
|
788
1860
|
}
|
|
789
1861
|
addConditionalFormattingRule(e) {
|
|
790
1862
|
const t = {
|
|
791
|
-
rule: e,
|
|
792
1863
|
unitId: this._workbook.getUnitId(),
|
|
793
|
-
subUnitId: this._worksheet.getSheetId()
|
|
1864
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1865
|
+
rule: e
|
|
794
1866
|
};
|
|
795
1867
|
return this._commandService.syncExecuteCommand(S.id, t), this;
|
|
796
1868
|
}
|
|
@@ -800,28 +1872,44 @@ class V extends R {
|
|
|
800
1872
|
subUnitId: this._worksheet.getSheetId(),
|
|
801
1873
|
cfId: e
|
|
802
1874
|
};
|
|
803
|
-
return this._commandService.syncExecuteCommand(
|
|
1875
|
+
return this._commandService.syncExecuteCommand(E.id, t), this;
|
|
804
1876
|
}
|
|
805
1877
|
moveConditionalFormattingRule(e, t, r = "after") {
|
|
806
|
-
const
|
|
1878
|
+
const l = {
|
|
807
1879
|
unitId: this._workbook.getUnitId(),
|
|
808
1880
|
subUnitId: this._worksheet.getSheetId(),
|
|
809
1881
|
start: { id: e, type: "self" },
|
|
810
1882
|
end: { id: t, type: r }
|
|
811
1883
|
};
|
|
812
|
-
return this._commandService.syncExecuteCommand(
|
|
1884
|
+
return this._commandService.syncExecuteCommand(k.id, l), this;
|
|
813
1885
|
}
|
|
814
1886
|
setConditionalFormattingRule(e, t) {
|
|
815
1887
|
const r = {
|
|
816
1888
|
unitId: this._workbook.getUnitId(),
|
|
817
1889
|
subUnitId: this._worksheet.getSheetId(),
|
|
818
|
-
|
|
819
|
-
|
|
1890
|
+
cfId: e,
|
|
1891
|
+
rule: t
|
|
820
1892
|
};
|
|
821
|
-
return this._commandService.syncExecuteCommand(
|
|
1893
|
+
return this._commandService.syncExecuteCommand(F.id, r), this;
|
|
1894
|
+
}
|
|
1895
|
+
clearConditionalFormatRules() {
|
|
1896
|
+
const e = {
|
|
1897
|
+
unitId: this._workbook.getUnitId(),
|
|
1898
|
+
subUnitId: this._worksheet.getSheetId()
|
|
1899
|
+
};
|
|
1900
|
+
return this._commandService.syncExecuteCommand(O.id, e), this;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
N.extend(G);
|
|
1904
|
+
class P {
|
|
1905
|
+
get ConditionFormatNumberOperatorEnum() {
|
|
1906
|
+
return s;
|
|
1907
|
+
}
|
|
1908
|
+
get ConditionFormatTimePeriodOperatorEnum() {
|
|
1909
|
+
return D;
|
|
822
1910
|
}
|
|
823
1911
|
}
|
|
824
|
-
|
|
1912
|
+
V.extend(P);
|
|
825
1913
|
export {
|
|
826
|
-
|
|
1914
|
+
w as FConditionalFormattingBuilder
|
|
827
1915
|
};
|