You can sort entire rows or columns automatically in a sheet. Automatically sort the rows in a sheet according to the specified column in ascending order unless the sheet was previously automatically sorted ascending. This also shows the sort indicator unless the sort indicator for the column has been disabled. This does not affect the data model, only how the data is displayed. Different overloads provide different ways to perform the sorting.
Use the AutoSortColumn method to sort the display in a sheet automatically according to the specified key and use the SetColumShowSortIndicator to set whether to show the sort indicator. The AutoSortColumn method performs the same action as clicking in the column header of the specified column that has its AllowAutoSort property set to True. (The AllowAutoSort property does not need to be set to True to use this method.) If this method is called successively with the same column index, then the direction of the sort is reversed. If the method is called with a different column index, then the previously sorted column's sort indicator is changed back to SortIndicator.None (if there is one) and the specified column is used as the key column in a call to SortRows to sort all the rows in the sheet by that column. This affects only the arrangement of rows or columns on a sheet and does not change the arrangement of the data; this does not affect the data model, only how the data is displayed. Several overloads of the method provide different ways to sort.
- Allow the automatic sorting of a column or columns.
- Set the column to show the sort indicator if desired.
- Perform the automatic sort.
This example automatically sorts the first column.
fpSpread1.ActiveSheet.SetColumnAllowAutoSort(0, true); fpSpread1.ActiveSheet.SetColumnShowSortIndicator(0, false); fpSpread1.ActiveSheet.AutoSortColumn(0);
fpSpread1.ActiveSheet.SetColumnAllowAutoSort(0, True) fpSpread1.ActiveSheet.SetColumnShowSortIndicator(0, False) fpSpread1.ActiveSheet.AutoSortColumn(0)