1
- Imports System
2
- Imports DevExpress.Spreadsheet
3
1
Imports System.Drawing
2
+ Imports DevExpress.Spreadsheet
4
3
5
4
Namespace SpreadsheetExamples
6
5
@@ -12,8 +11,8 @@ Namespace SpreadsheetExamples
12
11
Public CopyRowsColumnsAction As Action( Of Workbook) = AddressOf CopyRowsColumns
13
12
Public ShowHideRowsColumnsAction As Action( Of Workbook) = AddressOf ShowHideRowsColumns
14
13
Public SpecifyRowsHeightColumnsWidthAction As Action( Of Workbook) = AddressOf SpecifyRowsHeightColumnsWidth
15
- Public GroupRowsColumnsAction As Action( Of Workbook) = AddressOf GroupRowsColumns
16
- Public DeleteRowsBasedOnConditionAction As Action( Of Workbook) = AddressOf DeleteRowsBasedOnCondition
14
+ Public GroupRowsColumnsAction As Action( Of Workbook) = AddressOf GroupRowsColumns
15
+ Public DeleteRowsBasedOnConditionAction As Action( Of Workbook) = AddressOf DeleteRowsBasedOnCondition
17
16
Public DeleteColumnsBasedOnConditionAction As Action( Of Workbook) = AddressOf DeleteColumnsBasedOnCondition
18
17
# End Region
19
18
Private Sub InsertRowsColumns( ByVal workbook As Workbook)
@@ -176,74 +175,71 @@ Namespace SpreadsheetExamples
176
175
# End Region ' #GroupColumns
177
176
End Sub
178
177
179
- static void DeleteRowsBasedOnCondition(IWorkbook workbook)
180
- {
181
- # region #DeleteRowsBasedOnCondition
182
- // Load a document from a file.
183
- workbook.LoadDocument( "Documents\\Document.xlsx" ) ;
184
-
185
- // Access a worksheet.
186
- Worksheet worksheet = workbook.Worksheets [0 ];
187
-
188
- // Specify the condition to remove worksheet rows.
189
- // If a value in column "A" is greater than 3
190
- // and less than 14 , remove the corresponding row.
191
- Func<int, bool> rowRemovalCondition = x => worksheet.Cells [x, 0 ].Value.NumericValue > 3 . 0 && worksheet.Cells [x, 0 ].Value.NumericValue < 14 . 0 ;
192
-
193
- // Fill cells with data.
194
- for (int i = 0 ; i < 15 ; i++)
195
- {
196
- worksheet.Cells [i, 0 ].Value = i + 1 ;
197
- worksheet.Cells [0 , i ].Value = i + 1 ;
198
- }
199
-
200
- // Delete all rows that meet the specified condition.
201
- //worksheet.Rows.Remove(rowRemovalCondition) ;
202
-
203
- // Delete rows that meet the specified condition.
204
- // Check from the 8 th row.
205
- worksheet.Rows.Remove( 7 , rowRemovalCondition) ;
206
-
207
- // Delete rows that meet the specified condition.
208
- // Check rows 6 through 15 .
209
- //worksheet.Rows.Remove( 5 , 14 , rowRemovalCondition) ;
210
- #endregion #DeleteRowsBasedOnCondition
211
- }
212
-
213
- static void DeleteColumnsBasedOnCondition(IWorkbook workbook)
214
- {
215
- # region #DeleteColumnsBasedOnCondition
216
- // Load a document from a file.
217
- workbook.LoadDocument( "Documents\\Document.xlsx" ) ;
218
-
219
- // Access a worksheet.
220
- Worksheet worksheet = workbook.Worksheets [0 ];
221
-
222
- // Specify the condition to remove worksheet columns.
223
- // If a value in the first row is greater than 3
224
- // and less than 14 , remove the corresponding column.
225
- Func<int, bool> columnRemovalCondition = x => worksheet.Cells [0 , x ].Value.NumericValue > 3 . 0 && worksheet.Cells [0 , x ].Value.NumericValue < 14 . 0 ;
226
-
227
- // Fill cells with data.
228
- for (int i = 0 ; i < 15 ; i++)
229
- {
230
- worksheet.Cells [i, 0 ].Value = i + 1 ;
231
- worksheet.Cells [0 , i ].Value = i + 1 ;
232
- }
233
-
234
- // Delete all columns that meet the specified condition.
235
- //worksheet.Columns.Remove(columnRemovalCondition) ;
236
-
237
- // Delete columns that meet the specified condition.
238
- // Check from the 8 th column.
239
- worksheet.Columns.Remove( 7 , columnRemovalCondition) ;
240
-
241
- // Delete columns that meet the specified condition.
242
- // Check columns "F" through "O" .
243
- //worksheet.Columns.Remove( 5 , 14 , columnRemovalCondition) ;
244
-
245
- #endregion #DeleteColumnsBasedOnCondition
246
- }
178
+ Private Sub DeleteRowsBasedOnCondition( ByVal workbook As IWorkbook)
179
+ # Region "#DeleteRowsBasedOnCondition"
180
+ ' Load a document from a file.
181
+ workbook.LoadDocument( "Documents\Document.xlsx" )
182
+
183
+ ' Access a worksheet.
184
+ Dim worksheet As Worksheet = workbook.Worksheets( 0 )
185
+
186
+ ' Specify the condition to remove worksheet rows.
187
+ ' If a value in column "A" is greater than 3
188
+ ' and less than 14, remove the corresponding row.
189
+ Dim rowRemovalCondition As Func( Of Integer , Boolean ) = Function (x) worksheet.Cells(x, 0 ).Value.NumericValue > 3 . 0 AndAlso worksheet.Cells(x, 0 ).Value.NumericValue < 14 . 0
190
+
191
+ ' Fill cells with data.
192
+ For i As Integer = 0 To 14
193
+ worksheet.Cells(i, 0 ).Value = i + 1
194
+ worksheet.Cells( 0 , i).Value = i + 1
195
+ Next i
196
+
197
+ ' Delete all rows that meet the specified condition.
198
+ 'worksheet.Rows.Remove(rowRemovalCondition);
199
+
200
+ ' Delete rows that meet the specified condition.
201
+ ' Check from the 8th row.
202
+ worksheet.Rows.Remove( 7 , rowRemovalCondition)
203
+
204
+ ' Delete rows that meet the specified condition.
205
+ ' Check rows 6 through 15.
206
+ 'worksheet.Rows.Remove(5, 14, rowRemovalCondition);
207
+ # End Region
208
+ End Sub
209
+
210
+ Private Sub DeleteColumnsBasedOnCondition( ByVal workbook As IWorkbook)
211
+ # Region "#DeleteColumnsBasedOnCondition"
212
+ ' Load a document from a file.
213
+ workbook.LoadDocument( "Documents\Document.xlsx" )
214
+
215
+ ' Access a worksheet.
216
+ Dim worksheet As Worksheet = workbook.Worksheets( 0 )
217
+
218
+ ' Specify the condition to remove worksheet columns.
219
+ ' If a value in the first row is greater than 3
220
+ ' and less than 14, remove the corresponding column.
221
+ Dim columnRemovalCondition As Func( Of Integer , Boolean ) = Function (x) worksheet.Cells( 0 , x).Value.NumericValue > 3 . 0 AndAlso worksheet.Cells( 0 , x).Value.NumericValue < 14 . 0
222
+
223
+ ' Fill cells with data.
224
+ For i As Integer = 0 To 14
225
+ worksheet.Cells(i, 0 ).Value = i + 1
226
+ worksheet.Cells( 0 , i).Value = i + 1
227
+ Next i
228
+
229
+ ' Delete all columns that meet the specified condition.
230
+ 'worksheet.Columns.Remove(columnRemovalCondition);
231
+
232
+ ' Delete columns that meet the specified condition.
233
+ ' Check from the 8th column.
234
+ worksheet.Columns.Remove( 7 , columnRemovalCondition)
235
+
236
+ ' Delete columns that meet the specified condition.
237
+ ' Check columns "F" through "O".
238
+ 'worksheet.Columns.Remove(5, 14, columnRemovalCondition);
239
+
240
+ # End Region
241
+ End Sub
242
+
247
243
248
244
End Module
249
245
End Namespace
0 commit comments