Version

Sorting Worksheet in Infragistics Excel Engine

Topic Overview

Purpose

This topic explains how to configure and perform worksheet level sorting.

Required Background

The following table lists the concepts and topics required as a prerequisite to understanding this topic:

Topic Purpose

About Infragistics Excel Engine

In this section you will find information that will help you to better understand the object model and the functionalities of the Infragistics Excel Engine.

In this topic

This topic contains the following sections:

Sorting is done by setting a sorting condition on a worksheet level object on either column or row.You can sort columns or rows in ascending or descending order.

The sort conditions in a sheet are only reapplied when sort conditions are added, removed, modified, or when the ReapplySortConditions method is called on the sheet.Columns or rows will be sorted within the region. 'Rows' is the default sort type.

The following sort settings are available to set on rows:

Sort condition type Description

In worksheet Column/Row to be sorted based on their condition.

True or false depends whether strings should be compared case-sensitively when they are sorted.

Set the region to apply the sort setting.

Sort conditions to use when sorting the region of data.

The following sort condition types are available to set on columns:

Sort condition type Description

Sort cells in an ascending or descending order based on their value.

Sort cells in a defined order based on their text or display value. This might be useful for sorting as they appear on the calendar or as they appear in a custom list defined by you, rather than alphabetically.

Sort cells based on whether their fill is a specific pattern / gradient.

Sort cells based on whether their font is a specific color.

Code Example:

The following code snippet shows how to perform Worksheet level sorting on the Infragistics Excel Engine.Set the region to apply sorting from column B8 to column B15.

This example uses a code snippet for programmatically creating a workbook

Following is the code that implements this example.

In C#:

Worksheet Worksheet1 = Workbook.Worksheets[0];
Worksheet1.SortSettings.SortType = Infragistics.Documents.Excel.WorksheetSortType.Rows;
Worksheet1.SortSettings.CaseSensitive = true;
Worksheet1.SortSettings.SetRegion("B8:B15");
Worksheet1.SortSettings.SortConditions.Add(new RelativeIndex(0), new OrderedSortCondition(SortDirection.Ascending);

In Visual Basic:

Worksheet Worksheet1 = Workbook.Worksheets(0)
Worksheet1.SortSettings.SortType = Infragistics.Documents.Excel.WorksheetSortType.Rows
Worksheet1.SortSettings.CaseSensitive = True
Worksheet1.SortSettings.SetRegion("B8:B15")
Worksheet1.SortSettings.SortConditions.Add(New RelativeIndex(0), New OrderedSortCondition(SortDirection.Ascending)

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to show or hide the gridlines and set their color.

This topic explains how to show or hide the column and row headers.

This topic explains how to prevent the user from editing the cell values in a worksheet.