officefileapi-113765-spreadsheet-document-api-examples-filter-data-how-to-filter-top-or-bottom-ranked-values.md
This example demonstrates how to display the top/bottom ranked values using the "Top 10" filter.
Worksheet worksheet = workbook.Worksheets["Regional sales"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Enable filtering for the specified cell range.
CellRange range = worksheet["B2:E23"];
worksheet.AutoFilter.Apply(range);
// Apply a filter to the "Sales" column to display the top ten values.
worksheet.AutoFilter.Columns[2].ApplyTop10Filter(Top10Type.Top10Items, 10);
Dim worksheet As Worksheet = workbook.Worksheets("Regional sales")
workbook.Worksheets.ActiveWorksheet = worksheet
' Enable filtering for the specified cell range.
Dim range As CellRange = worksheet("B2:E23")
worksheet.AutoFilter.Apply(range)
' Apply a filter to the "Sales" column to display the top ten values.
worksheet.AutoFilter.Columns(2).ApplyTop10Filter(Top10Type.Top10Items, 10)