officefileapi-devexpress-dot-spreadsheet-dot-rowcollection-dot-remove-x28-system-dot-func-system-dot-int32-system-dot-boolean-x29.md
Removes rows that match the specified condition from the worksheet.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
void Remove(
Func<int, bool> predicate
)
Sub Remove(
predicate As Func(Of Integer, Boolean)
)
| Name | Type | Description |
|---|---|---|
| predicate | Func<Int32, Boolean> |
A delegate that is the function to check for a condition in each row.
|
workbook.LoadDocument("Documents\\Document.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
// Create a function specifying the condition to remove worksheet rows.
Func<int, bool> rowRemovalCondition = x => worksheet.Cells[x, 0].Value.NumericValue > 3.0 && worksheet.Cells[x, 0].Value.NumericValue < 14.0;
// Fill cells with data.
for (int i = 0; i < 15; i++)
{
worksheet.Cells[i, 0].Value = i + 1;
worksheet.Cells[0, i].Value = i + 1;
}
// Delete all rows that meet the specified condition.
//worksheet.Rows.Remove(rowRemovalCondition);
// Delete rows that meet the specified condition starting from the 7th row.
worksheet.Rows.Remove(7, rowRemovalCondition);
// Delete rows that meet the specified condition starting from the 5th row to the 14th row.
//worksheet.Rows.Remove(5, 14, rowRemovalCondition);
workbook.LoadDocument("Documents\Document.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Create a function specifying the condition to remove worksheet rows.
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
' Fill cells with data.
For i As Integer = 0 To 14
worksheet.Cells(i, 0).Value = i + 1
worksheet.Cells(0, i).Value = i + 1
Next i
' Delete all rows that meet the specified condition.
'worksheet.Rows.Remove(rowRemovalCondition);
' Delete rows that meet the specified condition starting from the 7th row.
worksheet.Rows.Remove(7, rowRemovalCondition)
' Delete rows that meet the specified condition starting from the 5th row to the 14th row.
'worksheet.Rows.Remove(5, 14, rowRemovalCondition);
See Also