@@ -12,7 +12,7 @@ static void ApplyFilter(Workbook workbook)
12
12
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
13
13
workbook . Worksheets . ActiveWorksheet = worksheet ;
14
14
15
- // Enable filtering for the specified cell range.
15
+ // Enable filtering for the "B2:E23" cell range.
16
16
CellRange range = worksheet [ "B2:E23" ] ;
17
17
worksheet . AutoFilter . Apply ( range ) ;
18
18
#endregion #ApplyFilter
@@ -24,11 +24,12 @@ static void FilterAndSortBySingleColumn(Workbook workbook)
24
24
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
25
25
workbook . Worksheets . ActiveWorksheet = worksheet ;
26
26
27
- // Enable filtering for the specified cell range.
27
+ // Enable filtering for the "B2:E23" cell range.
28
28
CellRange range = worksheet [ "B2:E23" ] ;
29
29
worksheet . AutoFilter . Apply ( range ) ;
30
30
31
- // Sort the data in descending order by the first column.
31
+ // Sort data in the "B2:E23" range
32
+ // in descending order by column "A".
32
33
worksheet . AutoFilter . SortState . Sort ( 0 , true ) ;
33
34
#endregion #FilterAndSortBySingleColumn
34
35
}
@@ -39,11 +40,12 @@ static void FilterAndSortByMultipleColumns(Workbook workbook)
39
40
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
40
41
workbook . Worksheets . ActiveWorksheet = worksheet ;
41
42
42
- // Enable filtering for the specified cell range.
43
+ // Enable filtering for the "B2:E23" cell range.
43
44
CellRange range = worksheet [ "B2:E23" ] ;
44
45
worksheet . AutoFilter . Apply ( range ) ;
45
46
46
- // Sort the data in descending order by the first and third columns.
47
+ // Sort data in the "B2:E23" range
48
+ // in descending order by columns "A" and "C".
47
49
List < SortCondition > sortConditions = new List < SortCondition > ( ) ;
48
50
sortConditions . Add ( new SortCondition ( 0 , true ) ) ;
49
51
sortConditions . Add ( new SortCondition ( 2 , true ) ) ;
@@ -57,7 +59,7 @@ static void FilterNumericByCondition(Workbook workbook)
57
59
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
58
60
workbook . Worksheets . ActiveWorksheet = worksheet ;
59
61
60
- // Enable filtering for the specified cell range.
62
+ // Enable filtering for the "B2:E23" cell range.
61
63
CellRange range = worksheet [ "B2:E23" ] ;
62
64
worksheet . AutoFilter . Apply ( range ) ;
63
65
@@ -73,7 +75,7 @@ static void FilterTextByCondition(Workbook workbook)
73
75
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
74
76
workbook . Worksheets . ActiveWorksheet = worksheet ;
75
77
76
- // Enable filtering for the specified cell range.
78
+ // Enable filtering for the "B2:E23" cell range.
77
79
CellRange range = worksheet [ "B2:E23" ] ;
78
80
worksheet . AutoFilter . Apply ( range ) ;
79
81
@@ -89,11 +91,11 @@ static void FilterByValue(Workbook workbook)
89
91
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
90
92
workbook . Worksheets . ActiveWorksheet = worksheet ;
91
93
92
- // Enable filtering for the specified cell range.
94
+ // Enable filtering for the "B2:E23" cell range.
93
95
CellRange range = worksheet [ "B2:E23" ] ;
94
96
worksheet . AutoFilter . Apply ( range ) ;
95
97
96
- // Filter the data in the "Product" column by a specific value.
98
+ // Filter data in the "Product" column by a specific value.
97
99
worksheet . AutoFilter . Columns [ 1 ] . ApplyFilterCriteria ( "Mozzarella di Giovanni" ) ;
98
100
#endregion #FilterBySingleValue
99
101
}
@@ -104,11 +106,11 @@ static void FilterByMultipleValues(Workbook workbook)
104
106
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
105
107
workbook . Worksheets . ActiveWorksheet = worksheet ;
106
108
107
- // Enable filtering for the specified cell range.
109
+ // Enable filtering for the "B2:E23" cell range.
108
110
CellRange range = worksheet [ "B2:E23" ] ;
109
111
worksheet . AutoFilter . Apply ( range ) ;
110
112
111
- // Filter the data in the "Product" column by an array of values.
113
+ // Filter data in the "Product" column by an array of values.
112
114
worksheet . AutoFilter . Columns [ 1 ] . ApplyFilterCriteria ( new CellValue [ ] { "Mozzarella di Giovanni" , "Gorgonzola Telino" } ) ;
113
115
#endregion #FilterByMultipleValues
114
116
}
@@ -119,12 +121,15 @@ static void FilterDatesByCondition(Workbook workbook)
119
121
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
120
122
workbook . Worksheets . ActiveWorksheet = worksheet ;
121
123
122
- // Enable filtering for the specified cell range.
124
+ // Enable filtering for the "B2:E23" cell range.
123
125
CellRange range = worksheet [ "B2:E23" ] ;
124
126
worksheet . AutoFilter . Apply ( range ) ;
125
127
126
- // Filter values in the "Reported Date" column to display dates that are between June 1, 2014 and February 1, 2015.
127
- worksheet . AutoFilter . Columns [ 3 ] . ApplyCustomFilter ( new DateTime ( 2014 , 6 , 1 ) , FilterComparisonOperator . GreaterThanOrEqual , new DateTime ( 2015 , 2 , 1 ) , FilterComparisonOperator . LessThanOrEqual , true ) ;
128
+ // Filter values in the "Reported Date" column
129
+ // to display dates that are between June 1, 2014 and February 1, 2015.
130
+ worksheet . AutoFilter . Columns [ 3 ] . ApplyCustomFilter
131
+ ( new DateTime ( 2014 , 6 , 1 ) , FilterComparisonOperator . GreaterThanOrEqual ,
132
+ new DateTime ( 2015 , 2 , 1 ) , FilterComparisonOperator . LessThanOrEqual , true ) ;
128
133
#endregion #FilterDatesByCondition
129
134
}
130
135
@@ -134,7 +139,7 @@ static void FilterMixedDataTypesByValues(Workbook workbook)
134
139
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
135
140
workbook . Worksheets . ActiveWorksheet = worksheet ;
136
141
137
- // Enable filtering for the specified cell range.
142
+ // Enable filtering for the "B2:E23" cell range.
138
143
CellRange range = worksheet [ "B2:E23" ] ;
139
144
worksheet . AutoFilter . Apply ( range ) ;
140
145
@@ -143,7 +148,8 @@ static void FilterMixedDataTypesByValues(Workbook workbook)
143
148
DateGrouping dateGroupingJan2015 = new DateGrouping ( new DateTime ( 2015 , 1 , 1 ) , DateTimeGroupingType . Month ) ;
144
149
groupings . Add ( dateGroupingJan2015 ) ;
145
150
146
- // Filter the data in the "Reported Date" column to display values reported in January 2015.
151
+ // Filter data in the "Reported Date" column
152
+ // to display values reported in January 2015.
147
153
worksheet . AutoFilter . Columns [ 3 ] . ApplyFilterCriteria ( "gennaio 2015" , groupings ) ;
148
154
#endregion #FilterMixedDataByValues
149
155
}
@@ -154,7 +160,7 @@ static void Top10FilterValue(Workbook workbook)
154
160
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
155
161
workbook . Worksheets . ActiveWorksheet = worksheet ;
156
162
157
- // Enable filtering for the specified cell range.
163
+ // Enable filtering for the "B2:E23" cell range.
158
164
CellRange range = worksheet [ "B2:E23" ] ;
159
165
worksheet . AutoFilter . Apply ( range ) ;
160
166
@@ -169,13 +175,15 @@ static void DynamicFilterValue(Workbook workbook)
169
175
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
170
176
workbook . Worksheets . ActiveWorksheet = worksheet ;
171
177
172
- // Enable filtering for the specified cell range.
178
+ // Enable filtering for the "B2:E23" cell range.
173
179
CellRange range = worksheet [ "B2:E23" ] ;
174
180
worksheet . AutoFilter . Apply ( range ) ;
175
181
176
- // Apply a dynamic filter to the "Sales" column to display only values that are above the average.
182
+ // Apply a dynamic filter to the "Sales" column
183
+ // to display only values that are above the average.
177
184
worksheet . AutoFilter . Columns [ 2 ] . ApplyDynamicFilter ( DynamicFilterType . AboveAverage ) ;
178
- // Apply a dynamic filter to the "Reported Date" column to display values reported this year.
185
+ // Apply a dynamic filter to the "Reported Date" column
186
+ // to display values reported this year.
179
187
worksheet . AutoFilter . Columns [ 3 ] . ApplyDynamicFilter ( DynamicFilterType . ThisYear ) ;
180
188
#endregion #DynamicFilter
181
189
}
@@ -186,14 +194,14 @@ static void ReapplyFilterValue(Workbook workbook)
186
194
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
187
195
workbook . Worksheets . ActiveWorksheet = worksheet ;
188
196
189
- // Enable filtering for the specified cell range.
197
+ // Enable filtering for the "B2:E23" cell range.
190
198
CellRange range = worksheet [ "B2:E23" ] ;
191
199
worksheet . AutoFilter . Apply ( range ) ;
192
200
193
201
// Filter values in the "Sales" column that are greater than 5000$.
194
202
worksheet . AutoFilter . Columns [ 2 ] . ApplyCustomFilter ( 5000 , FilterComparisonOperator . GreaterThan ) ;
195
203
196
- // Change the data and reapply the filter.
204
+ // Change data and reapply the filter.
197
205
worksheet [ "D3" ] . Value = 5000 ;
198
206
worksheet . AutoFilter . ReApply ( ) ;
199
207
#endregion #ReapplyFilter
@@ -205,7 +213,7 @@ static void ClearFilter(Workbook workbook)
205
213
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
206
214
workbook . Worksheets . ActiveWorksheet = worksheet ;
207
215
208
- // Enable filtering for the specified cell range.
216
+ // Enable filtering for the "B2:E23" cell range.
209
217
CellRange range = worksheet [ "B2:E23" ] ;
210
218
worksheet . AutoFilter . Apply ( range ) ;
211
219
@@ -223,7 +231,7 @@ static void DisableFilter(Workbook workbook)
223
231
Worksheet worksheet = workbook . Worksheets [ "Regional sales" ] ;
224
232
workbook . Worksheets . ActiveWorksheet = worksheet ;
225
233
226
- // Enable filtering for the specified cell range.
234
+ // Enable filtering for the "B2:E23" cell range.
227
235
CellRange range = worksheet [ "B2:E23" ] ;
228
236
worksheet . AutoFilter . Apply ( range ) ;
229
237
0 commit comments