-
Notifications
You must be signed in to change notification settings - Fork 63
/
excel.conditionalformattype.yml
97 lines (84 loc) · 4.03 KB
/
excel.conditionalformattype.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
### YamlMime:TSEnum
name: Excel.ConditionalFormatType
uid: 'excel!Excel.ConditionalFormatType:enum'
package: excel!
fullName: Excel.ConditionalFormatType
summary: ''
remarks: >-
\[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
queueCommandsToClearAllConditionalFormats(sheet);
const temperatureDataRange = sheet.tables.getItem("TemperatureTable").getDataBodyRange();
/* When the priority property of ConditionalFormat objects
is not explicitly set, they are prioritized in the order
that they are added, with zero-based numbering: 0, 1, ...
Contradictions are resolved in favor of the format with
the lower priority number. In the example below, negative
numbers will get a green background, but NOT a blue font,
because priority goes to the format that gives them a red font.
*/
// Set low numbers to bold, dark red font. This format will
// get priority 0.
const presetFormat = temperatureDataRange.conditionalFormats
.add(Excel.ConditionalFormatType.presetCriteria);
presetFormat.preset.format.font.color = "red";
presetFormat.preset.format.font.bold = true;
presetFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevBelowAverage };
// Set negative numbers to blue font with green background.
// This format will get priority 1.
const cellValueFormat = temperatureDataRange.conditionalFormats
.add(Excel.ConditionalFormatType.cellValue);
cellValueFormat.cellValue.format.font.color = "blue";
cellValueFormat.cellValue.format.fill.color = "lightgreen";
cellValueFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" };
await context.sync();
});
```
isPreview: false
isDeprecated: false
fields:
- name: cellValue
uid: 'excel!Excel.ConditionalFormatType.cellValue:member'
package: excel!
summary: '* \[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
value: '"CellValue"'
- name: colorScale
uid: 'excel!Excel.ConditionalFormatType.colorScale:member'
package: excel!
summary: '* \[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
value: '"ColorScale"'
- name: containsText
uid: 'excel!Excel.ConditionalFormatType.containsText:member'
package: excel!
summary: '* \[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
value: '"ContainsText"'
- name: custom
uid: 'excel!Excel.ConditionalFormatType.custom:member'
package: excel!
summary: '* \[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
value: '"Custom"'
- name: dataBar
uid: 'excel!Excel.ConditionalFormatType.dataBar:member'
package: excel!
summary: '* \[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
value: '"DataBar"'
- name: iconSet
uid: 'excel!Excel.ConditionalFormatType.iconSet:member'
package: excel!
summary: '* \[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
value: '"IconSet"'
- name: presetCriteria
uid: 'excel!Excel.ConditionalFormatType.presetCriteria:member'
package: excel!
summary: '* \[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
value: '"PresetCriteria"'
- name: topBottom
uid: 'excel!Excel.ConditionalFormatType.topBottom:member'
package: excel!
summary: '* \[ [API set: ExcelApi 1.6](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
value: '"TopBottom"'