答案 0 :(得分:0)
Excel.PivotField pf = (Excel.PivotField)pvtTable.PivotFields("Sport");
//Desired list order.
List<string> oListOrder = new List<string>() { "Football", "Tennis", "Baseball", "Softball" };
foreach (Excel.PivotItem pi in pf.PivotItems()) {
//Get index in desired list order.
int idx = oColumnSort.IndexOf(pi.Name);
//If PivotItem in ordered list set PivotItem position to that of list.
//Add 1 bc Position & List have different starting base.
if (idx >= 0) pi.Position = idx + 1;
}