答案 0 :(得分:2)
EPPlus无法按栏排序:https://epplus.codeplex.com/workitem/14791
这不是你要求的,但是如果这有助于excel互操作,你可以按照这样的列排序:
Worksheet sheet = workBook.Sheets[1];
Range sortRange = sheet.Range["A1", "S100"];
sortRange.Sort(sortRange.Columns[5], Microsoft.Office.Interop.Excel.XlSortOrder.xlDescending);
这将按E列对范围A1:S100进行排序。
答案 1 :(得分:0)
var startRow = 1;
var startColumn= 1;
var endRow= 10;
var endColumn= 10;
var sortColumn = 5; //6th Column because index is ZeroBased.
using (ExcelRange excelRange = yourWorkSheet.Cells[startRow, startColumn, endRow, endColumn])
{
excelRange.Sort(sortColumn, true);
}
答案 2 :(得分:0)
Jan Kallman在4.5.1中发布了一种排序方法。您可以在此处看到他显示的示例:
https://github.com/JanKallman/EPPlus/issues/78#issuecomment-349650208
/// Sort the range by value
/// </summary>
/// <param name="columns">The column(s) to sort by within the range. Zerobased</param>
/// <param name="descending">Descending if true, otherwise Ascending. Default Ascending. Zerobased</param>
/// <param name="culture">The CultureInfo used to compare values. A null value means CurrentCulture</param>
/// <param name="compareOptions">String compare option</param>
public void Sort(int[] columns, bool[] descending=null, CultureInfo culture=null, CompareOptions compareOptions=CompareOptions.None)
答案 3 :(得分:-6)
使用工作表
的autofilter()属性