EPPlus的数据透视表与错误的列字段顺序

我创build了一个数据透视表,它应该包含YEAR,MONTH和DAY这几列。

以下是列的代码:

//Column Year pvt.ColumnFields.Add(pvt.Fields[sheet.Cells[2, 2].Value.ToString()]); //Column Month pvt.ColumnFields.Add(pvt.Fields[sheet.Cells[2, 3].Value.ToString()]); //Column Day pvt.ColumnFields.Add(pvt.Fields[sheet.Cells[2, 4].Value.ToString()]); //Sort by the last column = day because if first row from data table is for example 10 all the other months start 10 in the columns fields and then after the 30/31 the library adds 1 to 9. pvt.ColumnFields[pvt.ColumnFields.Count - 1].Sort = OfficeOpenXml.Table.PivotTable.eSortType.Ascending; 

Excel中的结果:

列年Year)>月份>日 (OK)

图片1

它工作正常,但如果我在开始时添加另一列,分组列出错!!!

  //Column account if (addAccount == true) { pvt.ColumnFields.Add(pvt.Fields[sheet.Cells[2, 9].Value.ToString()]); } //Column Year pvt.ColumnFields.Add(pvt.Fields[sheet.Cells[2, 2].Value.ToString()]); //Column Month pvt.ColumnFields.Add(pvt.Fields[sheet.Cells[2, 3].Value.ToString()]); //Column Day pvt.ColumnFields.Add(pvt.Fields[sheet.Cells[2, 4].Value.ToString()]); //Sort by the last column = day because if first row from data table is for example 10 all the other months start 10 in the columns fields and then after the 30/31 the library adds 1 to 9. pvt.ColumnFields[pvt.ColumnFields.Count - 1].Sort = OfficeOpenXml.Table.PivotTable.eSortType.Ascending; 

结果在excel中:

列: 帐户>日>月份>年 (错误)

它应该是: 帐户>年份>月份>日 (确定)

在这里输入图像说明

那么,这是什么问题呢?