Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,25 @@ using (ExcelEngine excelEngine = new ExcelEngine())
IDataSort sorter = workbook.CreateDataSorter();

//Range to sort
sorter.SortRange = worksheet.Range["A1:A11"];
sorter.SortRange = worksheet.Range["A1:B11"];

//Adds the sort field with the column index, sort based on and order by attribute
//Adds a sort field: sort by values in column A in ascending order
sorter.SortFields.Add(0, SortOn.Values, OrderBy.Ascending);

//Adds a sort field: then by values in column B in descending order
sorter.SortFields.Add(1, SortOn.Values, OrderBy.Descending);

//Sort based on the sort Field attribute
sorter.Sort();

//Creates the data sorter
sorter = workbook.CreateDataSorter();

//Range to sort
sorter.SortRange = worksheet.Range["B1:B11"];
sorter.SortRange = worksheet.Range["C1:C11"];

//Adds the sort field with the column index, sort based on and order by attribute
sorter.SortFields.Add(1, SortOn.Values, OrderBy.Descending);
//Adds a sort field: sort by values in column C in descending order
sorter.SortFields.Add(2, SortOn.Values, OrderBy.Descending);

//Sort based on the sort Field attribute
sorter.Sort();
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,25 @@ static void Main(string[] args)
IDataSort sorter = workbook.CreateDataSorter();

//Range to sort
sorter.SortRange = worksheet.Range["A1:A11"];
sorter.SortRange = worksheet.Range["A1:B11"];

//Adds the sort field with the column index, sort based on and order by attribute
//Adds a sort field: sort by values in column A in ascending order
sorter.SortFields.Add(0, SortOn.Values, OrderBy.Ascending);

//Adds a sort field: then by values in column B in descending order
sorter.SortFields.Add(1, SortOn.Values, OrderBy.Descending);

//Sort based on the sort Field attribute
sorter.Sort();

//Creates the data sorter
sorter = workbook.CreateDataSorter();

//Range to sort
sorter.SortRange = worksheet.Range["B1:B11"];
sorter.SortRange = worksheet.Range["C1:C11"];

//Adds the sort field with the column index, sort based on and order by attribute
sorter.SortFields.Add(1, SortOn.Values, OrderBy.Descending);
//Adds a sort field: sort by values in column C in descending order
sorter.SortFields.Add(2, SortOn.Values, OrderBy.Descending);

//Sort based on the sort Field attribute
sorter.Sort();
Expand Down