EPPlus在DataField上sorting数据透视表,而不是RowField

我已经使用EPPlus工具包3.1版在工作表中创build了Excel数据透视表。 我能够sorting行字段上的结果表,但希望能够在数据字段上做到这一点。 作为一个例子,我从这里下载了3.1源代码:

EEPlus 3.1源代码

其中有一个称为CreatePivotTable()的unit testing。 它包含一个“数据”标签,看起来像这样:

var ws = _pck.Workbook.Worksheets.Add("Data"); ws.Cells["K1"].Value = "Item"; ws.Cells["L1"].Value = "Category"; ws.Cells["M1"].Value = "Stock"; ws.Cells["N1"].Value = "Price"; ws.Cells["O1"].Value = "Date for grouping"; ... 

然后testing添加了9个数据透视表。 看第一个,代码是这样的:

 var pt = wsPivot1.PivotTables.Add(wsPivot1.Cells["A1"], ws.Cells["K1:N11"], "Pivottable1"); pt.GrandTotalCaption = "Total amount"; pt.RowFields.Add(pt.Fields[1]); pt.RowFields.Add(pt.Fields[0]); pt.DataFields.Add(pt.Fields[3]); pt.DataFields.Add(pt.Fields[2]); pt.DataFields[0].Function = DataFieldFunctions.Product; pt.DataOnRows = false; 

因为没有sorting。 如果我对主要数据透视字段集合的第一个字段应用sorting,这也是两个行字段中的第二个字段:

 pt.Fields[0].Sort = eSortType.Descending; 

但是,如果我想要像这样sortingDataFields(都指向“价格”:

 pt.Fields[2].Sort = eSortType.Descending; //or pt.DataFields[0].Field.Sort = eSortType.Ascending; 

sorting不适用。 它工作正常,如果我在Excel中做,并手动添加。 另外,我在另一个项目上使用NetOffice,也可以这样做。 这不是EPPLus能做的吗?