zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
#region TODO
//TODO: Add the "DataBar" extended options
//TODO: Add tests for all the rules
//TODO: Add the IconSet options
//TODO: Add all the "extList" options
#endregion
 
#region §18.3.1.18 conditionalFormatting (Conditional Formatting)
//Childs:
//cfRule          (Conditional Formatting Rule) §18.3.1.10
//extLst          (Future Feature Data Storage Area) §18.2.10
 
//Attributes:
//pivot
//sqref           ST_Sqref simple type (§18.18.76)
#endregion
 
#region §18.3.1.10 cfRule (Conditional Formatting Rule)
//Childs:
//colorScale      (Color Scale) §18.3.1.16
//dataBar         (Data Bar) §18.3.1.28
//extLst          (Future Feature Data Storage Area) §18.2.10
//formula         (Formula) §18.3.1.43
//iconSet         (Icon Set) §18.3.1.49
 
//Attributes:
//-----------
//priority        (Priority) The priority of this conditional formatting rule. This value is used to determine which
//                format should be evaluated and rendered. Lower numeric values are higher priority than
//                higher numeric values, where 1 is the highest priority.
//stopIfTrue      (Stop If True) If this flag is 1, no rules with lower priority shall be applied over this rule, when this rule
//                evaluates to true.
//type            (Type) Type of conditional formatting rule. ST_CfType §18.18.12.
//aboveAverage    Indicates whether the rule is an "above average" rule. 1 indicates 'above average'.
//                This attribute is ignored if type is not equal to aboveAverage.
//equalAverage    (Equal Average)
//                Flag indicating whether the 'aboveAverage' and 'belowAverage' criteria is inclusive of the
//                average itself, or exclusive of that value. 1 indicates to include the average value in the
//                criteria. This attribute is ignored if type is not equal to aboveAverage.
//bottom          (Bottom N) Indicates whether a "top/bottom n" rule is a "bottom n" rule. 1 indicates 'bottom'.
//                This attribute is ignored if type is not equal to top10.
//dxfId           (Differential Formatting Id)
//                This is an index to a dxf element in the Styles Part indicating which cell formatting to
//                apply when the conditional formatting rule criteria is met. ST_DxfId simple type (§18.18.25).
//operator        (Operator) The operator in a "cell value is" conditional formatting rule. This attribute is ignored if
//                type is not equal to cellIs. The possible values ST_ConditionalFormattingOperator simple type (§18.18.15).
//percent         (Top 10 Percent)
//                Indicates whether a "top/bottom n" rule is a "top/bottom n percent" rule. This attribute
//                is ignored if type is not equal to top10.
//rank            (Rank) The value of "n" in a "top/bottom n" conditional formatting rule. This attribute is ignored
//                if type is not equal to top10.
//stdDev          (StdDev) The number of standard deviations to include above or below the average in the
//                conditional formatting rule. This attribute is ignored if type is not equal to aboveAverage.
//                If a value is present for stdDev and the rule type = aboveAverage, then this rule is automatically an
//                "above or below N standard deviations" rule.
//text            (Text) The text value in a "text contains" conditional formatting rule. This attribute is ignored if
//                type is not equal to containsText.
//timePeriod      (Time Period) The applicable time period in a "date occurring…" conditional formatting rule. This
//                attribute is ignored if type is not equal to timePeriod. ST_TimePeriod §18.18.82.
#endregion
 
#region Conditional Formatting XML examples
// All the examples are assumed to be inside <conditionalFormatting sqref="A1:A10">
 
#region Example "beginsWith"
//<x:cfRule type="beginsWith" dxfId="6" priority="5" operator="beginsWith" text="a">
//  <x:formula>LEFT(A1,LEN("a"))="a"</x:formula>
//</x:cfRule>
 
//<x:cfRule type="beginsWith" dxfId="5" priority="14" operator="beginsWith" text="&quot;&lt;&gt;">
//  <x:formula>LEFT(A3,LEN("""&lt;&gt;"))="""&lt;&gt;"</x:formula>
//</x:cfRule>
#endregion
 
#region Example "between"
//<x:cfRule type="cellIs" dxfId="8" priority="10" operator="between">
//  <x:formula>3</x:formula>
//  <x:formula>7</x:formula>
//</x:cfRule>
#endregion
 
#region Example "containsText"
//<x:cfRule type="containsText" dxfId="5" priority="4" operator="containsText" text="c">
//  <x:formula>NOT(ISERROR(SEARCH("c",A1)))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "endsWith"
//<x:cfRule type="endsWith" dxfId="9" priority="11" operator="endsWith" text="c">
//  <x:formula>RIGHT(A1,LEN("c"))="c"</x:formula>
//</x:cfRule>
#endregion
 
#region Example "equal"
//<x:cfRule type="cellIs" dxfId="7" priority="8" operator="equal">
//  <x:formula>"ab"</x:formula>
//</x:cfRule>
#endregion
 
#region Example "greaterThan"
//<x:cfRule type="cellIs" dxfId="6" priority="7" operator="greaterThan">
//  <x:formula>4</x:formula>
//</x:cfRule>
#endregion
 
#region Example "greaterThanOrEqual"
//<x:cfRule type="cellIs" dxfId="3" priority="4" operator="greaterThanOrEqual">
//  <x:formula>4</x:formula>
//</x:cfRule>
#endregion
 
#region Example "lessThan"
//<x:cfRule type="cellIs" dxfId="5" priority="6" operator="lessThan">
//  <x:formula>4</x:formula>
//</x:cfRule>
#endregion
 
#region Example "lessThanOrEqual"
//<x:cfRule type="cellIs" dxfId="4" priority="5" operator="lessThanOrEqual">
//  <x:formula>4</x:formula>
//</x:cfRule>
#endregion
 
#region Example "notBetween"
//<x:cfRule type="cellIs" dxfId="2" priority="3" operator="notBetween">
//  <x:formula>3</x:formula>
//  <x:formula>7</x:formula>
//</x:cfRule>
#endregion
 
#region Example "notContainsText"
//<x:cfRule type="notContainsText" dxfId="4" priority="3" operator="notContains" text="c">
//  <x:formula>ISERROR(SEARCH("c",A1))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "notEqual"
//<x:cfRule type="cellIs" dxfId="1" priority="2" operator="notEqual">
//  <x:formula>"ab"</x:formula>
//</x:cfRule>
#endregion
 
#region Example "containsBlanks"
//<x:cfRule type="containsBlanks" dxfId="20" priority="37">
//  <x:formula>LEN(TRIM(A1))=0</x:formula>
//</x:cfRule>
#endregion
 
#region Example "containsErrors"
//<x:cfRule type="containsErrors" dxfId="15" priority="19">
//  <x:formula>ISERROR(A1)</x:formula>
//</x:cfRule>
#endregion
 
#region Example "expression"
//<x:cfRule type="expression" dxfId="0" priority="1">
//  <x:formula>RIGHT(J16,1)="b"</x:formula>
//</x:cfRule>
#endregion
 
#region Example "duplicateValues"
//<x:cfRule type="duplicateValues" dxfId="14" priority="16" />
#endregion
 
#region Example "notContainsBlanks"
//<x:cfRule type="notContainsBlanks" dxfId="12" priority="14">
//  <x:formula>LEN(TRIM(A1))&gt;0</x:formula>
//</x:cfRule>
#endregion
 
#region Example "notContainsErrors"
//<x:cfRule type="notContainsErrors" dxfId="11" priority="36">
//  <x:formula>NOT(ISERROR(A1))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "uniqueValues"
//<x:cfRule type="uniqueValues" dxfId="13" priority="15" />
#endregion
 
#region Example "last7Days"
//<x:cfRule type="timePeriod" dxfId="39" priority="10" timePeriod="last7Days">
//  <x:formula>AND(TODAY()-FLOOR(A1,1)&lt;=6,FLOOR(A1,1)&lt;=TODAY())</x:formula>
//</x:cfRule>
#endregion
 
#region Example "lastMonth"
//<x:cfRule type="timePeriod" dxfId="38" priority="9" timePeriod="lastMonth">
//  <x:formula>AND(MONTH(A1)=MONTH(EDATE(TODAY(),0-1)),YEAR(A1)=YEAR(EDATE(TODAY(),0-1)))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "lastWeek"
//<x:cfRule type="timePeriod" dxfId="37" priority="8" timePeriod="lastWeek">
//  <x:formula>AND(TODAY()-ROUNDDOWN(A1,0)&gt;=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(A1,0)&lt;(WEEKDAY(TODAY())+7))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "nextMonth"
//<x:cfRule type="timePeriod" dxfId="36" priority="7" timePeriod="nextMonth">
//  <x:formula>AND(MONTH(A1)=MONTH(EDATE(TODAY(),0+1)),YEAR(A1)=YEAR(EDATE(TODAY(),0+1)))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "nextWeek"
//<x:cfRule type="timePeriod" dxfId="35" priority="6" timePeriod="nextWeek">
//  <x:formula>AND(ROUNDDOWN(A1,0)-TODAY()&gt;(7-WEEKDAY(TODAY())),ROUNDDOWN(A1,0)-TODAY()&lt;(15-WEEKDAY(TODAY())))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "thisMonth"
//<x:cfRule type="timePeriod" dxfId="34" priority="5" timePeriod="thisMonth">
//  <x:formula>AND(MONTH(A1)=MONTH(TODAY()),YEAR(A1)=YEAR(TODAY()))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "thisWeek"
//<x:cfRule type="timePeriod" dxfId="33" priority="4" timePeriod="thisWeek">
//  <x:formula>AND(TODAY()-ROUNDDOWN(A1,0)&lt;=WEEKDAY(TODAY())-1,ROUNDDOWN(A1,0)-TODAY()&lt;=7-WEEKDAY(TODAY()))</x:formula>
//</x:cfRule>
#endregion
 
#region Example "today"
//<x:cfRule type="timePeriod" dxfId="32" priority="3" timePeriod="today">
//  <x:formula>FLOOR(A1,1)=TODAY()</x:formula>
//</x:cfRule>
#endregion
 
#region Example "tomorrow"
//<x:cfRule type="timePeriod" dxfId="31" priority="2" timePeriod="tomorrow">
//  <x:formula>FLOOR(A1,1)=TODAY()+1</x:formula>
//</x:cfRule>
#endregion
 
#region Example "yesterday"
//<x:cfRule type="timePeriod" dxfId="1" priority="1" timePeriod="yesterday">
//  <x:formula>FLOOR(A1,1)=TODAY()-1</x:formula>
//</x:cfRule>
#endregion
 
#region Example "twoColorScale"
//<cfRule type="colorScale" priority="1">
//  <colorScale>
//    <cfvo type="min"/>
//    <cfvo type="max"/>
//    <color rgb="FFF8696B"/>
//    <color rgb="FF63BE7B"/>
//  </colorScale>
//</cfRule>
#endregion
 
#region Examples "iconSet3" (x all the 3 IconSet options)
//<x:cfRule type="iconSet" priority="30">
//  <x:iconSet>
//    <x:cfvo type="percent" val="0" />
//    <x:cfvo type="percent" val="33" />
//    <x:cfvo type="percent" val="67" />
//  </x:iconSet>
//</x:cfRule>
 
//<x:cfRule type="iconSet" priority="38">
//  <x:iconSet iconSet="3Arrows">
//    <x:cfvo type="percent" val="0" />
//    <x:cfvo type="percent" val="33" />
//    <x:cfvo type="percent" val="67" />
//  </x:iconSet>
//</x:cfRule>
#endregion
 
#region Examples "iconSet4" (x all the 4 IconSet options)
//<x:cfRule type="iconSet" priority="34">
//  <x:iconSet iconSet="4ArrowsGray">
//    <x:cfvo type="percent" val="0" />
//    <x:cfvo type="percent" val="25" />
//    <x:cfvo type="percent" val="50" />
//    <x:cfvo type="percent" val="75" />
//  </x:iconSet>
//</x:cfRule>
#endregion
 
#region Examples "iconSet5" (x all the 5 IconSet options)
//<x:cfRule type="iconSet" priority="32">
//  <x:iconSet iconSet="5ArrowsGray">
//    <x:cfvo type="percent" val="0" />
//    <x:cfvo type="percent" val="20" />
//    <x:cfvo type="percent" val="40" />
//    <x:cfvo type="percent" val="60" />
//    <x:cfvo type="percent" val="80" />
//  </x:iconSet>
//</x:cfRule>
#endregion
 
#region Examples "iconSet" Extended (not implemented yet)
//<x:extLst>
//  <x:ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{78C0D931-6437-407d-A8EE-F0AAD7539E65}">
//    <x14:conditionalFormattings>
//      <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
//        <x14:cfRule type="iconSet" priority="35" id="{F5114369-080A-47E6-B7EE-499137A3C896}">
//          <x14:iconSet iconSet="3Triangles">
//            <x14:cfvo type="percent">
//              <xm:f>0</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>33</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>67</xm:f>
//            </x14:cfvo>
//          </x14:iconSet>
//        </x14:cfRule>
//        <xm:sqref>C3:C12</xm:sqref>
//      </x14:conditionalFormatting>
//      <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
//        <x14:cfRule type="iconSet" priority="6" id="{0A327384-BF2F-4BF5-9767-123CD690A536}">
//          <x14:iconSet iconSet="3Stars">
//            <x14:cfvo type="percent">
//              <xm:f>0</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>33</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>67</xm:f>
//            </x14:cfvo>
//          </x14:iconSet>
//        </x14:cfRule>
//        <xm:sqref>A16:A25</xm:sqref>
//      </x14:conditionalFormatting>
//      <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
//        <x14:cfRule type="iconSet" priority="19" id="{0DDCA3E4-3536-44B3-A663-4877587295B8}">
//          <x14:iconSet iconSet="3Triangles">
//            <x14:cfvo type="percent">
//              <xm:f>0</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>33</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>67</xm:f>
//            </x14:cfvo>
//          </x14:iconSet>
//        </x14:cfRule>
//        <xm:sqref>C16:C25</xm:sqref>
//      </x14:conditionalFormatting>
//      <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
//        <x14:cfRule type="iconSet" priority="2" id="{E4EDD7FB-880C-408F-B87C-C8DA446AEB78}">
//          <x14:iconSet iconSet="5Boxes">
//            <x14:cfvo type="percent">
//              <xm:f>0</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>20</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>40</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>60</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="percent">
//              <xm:f>80</xm:f>
//            </x14:cfvo>
//          </x14:iconSet>
//        </x14:cfRule>
//        <xm:sqref>E16:E25</xm:sqref>
//      </x14:conditionalFormatting>
//      <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
//        <x14:cfRule type="iconSet" priority="1" id="{4CC82060-CB0A-4A31-AEF2-D1A587AC1674}">
//          <x14:iconSet iconSet="3Stars" showValue="0" custom="1">
//            <x14:cfvo type="percent">
//              <xm:f>0</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="formula">
//              <xm:f>$F$17</xm:f>
//            </x14:cfvo>
//            <x14:cfvo type="num">
//              <xm:f>4</xm:f>
//            </x14:cfvo>
//            <x14:cfIcon iconSet="3Triangles" iconId="1" />
//            <x14:cfIcon iconSet="4RedToBlack" iconId="3" />
//            <x14:cfIcon iconSet="3Stars" iconId="2" />
//          </x14:iconSet>
//        </x14:cfRule>
//        <xm:sqref>F16:F25</xm:sqref>
//      </x14:conditionalFormatting>
//    </x14:conditionalFormattings>
//  </x:ext>
//</x:extLst>
#endregion
 
 
#endregion