Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4bf146a

Browse files
update methods
1 parent 531c14b commit 4bf146a

File tree

1 file changed

+68
-72
lines changed

1 file changed

+68
-72
lines changed

‎VB/SpreadsheetExamples/SpreadsheetActions/RowAndColumnActions.vb

Lines changed: 68 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
Imports System
2-
Imports DevExpress.Spreadsheet
31
Imports System.Drawing
2+
Imports DevExpress.Spreadsheet
43

54
Namespace SpreadsheetExamples
65

@@ -12,8 +11,8 @@ Namespace SpreadsheetExamples
1211
Public CopyRowsColumnsAction As Action(Of Workbook) = AddressOf CopyRowsColumns
1312
Public ShowHideRowsColumnsAction As Action(Of Workbook) = AddressOf ShowHideRowsColumns
1413
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
1716
Public DeleteColumnsBasedOnConditionAction As Action(Of Workbook) = AddressOf DeleteColumnsBasedOnCondition
1817
#End Region
1918
Private Sub InsertRowsColumns(ByVal workbook As Workbook)
@@ -176,74 +175,71 @@ Namespace SpreadsheetExamples
176175
#End Region ' #GroupColumns
177176
End Sub
178177

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 8th 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 8th 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+
247243

248244
End Module
249245
End Namespace

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /