officefileapi-devexpress-dot-spreadsheet-dot-columncollection-dot-remove-x28-system-dot-int32-system-dot-func-system-dot-int32-system-dot-boolean-x29.md
Removes columns 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(
int first,
Func<int, bool> predicate
)
Sub Remove(
first As Integer,
predicate As Func(Of Integer, Boolean)
)
| Name | Type | Description |
|---|---|---|
| first | Int32 |
An integer that is the index of the column from which the check should start.
| | predicate | Func<Int32, Boolean> |
A function to test for a condition in each column.
|
workbook.LoadDocument("Documents\\Document.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
// Create a function specifying the condition to remove worksheet columns.
Func<int, bool> columnRemovalCondition = x => worksheet.Cells[0, x].Value.NumericValue > 3.0 && worksheet.Cells[0, x].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 columns that meet the specified condition.
//worksheet.Columns.Remove(columnRemovalCondition);
// Delete columns that meet the specified condition starting from the 7th column.
worksheet.Columns.Remove(7, columnRemovalCondition);
// Delete columns that meet the specified condition starting from the 5th column to the 14th column.
//worksheet.Columns.Remove(5, 14, columnRemovalCondition);
workbook.LoadDocument("Documents\Document.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Create a function specifying the condition to remove worksheet columns.
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
' 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 columns that meet the specified condition.
'worksheet.Columns.Remove(columnRemovalCondition);
' Delete columns that meet the specified condition starting from the 7th column.
worksheet.Columns.Remove(7, columnRemovalCondition)
' Delete columns that meet the specified condition starting from the 5th column to the 14th column.
'worksheet.Columns.Remove(5, 14, columnRemovalCondition);
The following code snippets (auto-collected from DevExpress Examples) contain references to the Remove(Int32, Func<Int32, Boolean>) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
// Delete columns that meet the specified condition starting from the 7th column.
worksheet.Columns.Remove(7, columnRemovalCondition);
// Delete columns that meet the specified condition starting from the 7th column.
worksheet.Columns.Remove(7, columnRemovalCondition);
// Check from the 8th column.
worksheet.Columns.Remove(7, columnRemovalCondition);
' Delete columns that meet the specified condition starting from the 7th column.
worksheet.Columns.Remove(7, columnRemovalCondition)
' Delete columns that meet the specified condition starting from the 5th column to the 14th column.
' Check from the 8th column.
worksheet.Columns.Remove(7, columnRemovalCondition)
See Also