/// <summary> /// Updates the grand totals backing data. /// </summary> /// <returns>The list of values used to calcluate grand-grand totals.</returns> public PivotCellBackingData[] UpdateGrandTotals(out List <PivotCellBackingData> grandTotalBackingData) { var grandTotalValueLists = new PivotCellBackingData[this.PivotTable.DataFields.Count]; var grandGrandTotalValueLists = new PivotCellBackingData[this.PivotTable.DataFields.Count]; grandTotalBackingData = new List <PivotCellBackingData>(); for (int majorIndex = 0; majorIndex < this.MajorHeaderCollection.Count; majorIndex++) { // Reset values lists. for (int i = 0; i < grandTotalValueLists.Count(); i++) { grandTotalValueLists[i] = null; } var majorHeader = this.MajorHeaderCollection[majorIndex]; int dataFieldCollectionIndex = -1; int minorIndex = 0; for (; minorIndex < this.MinorHeaderCollection.Count; minorIndex++) { dataFieldCollectionIndex = this.AddMatchingValues(majorHeader, majorIndex, minorIndex, dataFieldCollectionIndex, grandTotalValueLists, grandGrandTotalValueLists); } if (dataFieldCollectionIndex != -1) { this.CalculateBackingDataTotal(majorIndex, grandTotalValueLists, majorHeader.TotalType); foreach (var grandTotalBackingCell in grandTotalValueLists.Where(t => t != null)) { grandTotalBackingCell.MajorAxisIndex = majorIndex; grandTotalBackingData.Add(grandTotalBackingCell); } } } return(grandGrandTotalValueLists); }
/// <summary> /// Updates the grand totals in the pivot table. /// </summary> /// <returns>The list of values used to calcluate grand-grand totals.</returns> public PivotCellBackingData[] UpdateGrandTotals() { var grandTotalValueLists = new PivotCellBackingData[this.PivotTable.DataFields.Count]; var grandGrandTotalValueLists = new PivotCellBackingData[this.PivotTable.DataFields.Count]; for (int majorIndex = 0; majorIndex < this.MajorHeaderCollection.Count; majorIndex++) { // Reset values lists. for (int i = 0; i < grandTotalValueLists.Count(); i++) { grandTotalValueLists[i] = null; } var majorHeader = this.MajorHeaderCollection[majorIndex]; int dataFieldCollectionIndex = -1; int minorIndex = 0; for (; minorIndex < this.MinorHeaderCollection.Count; minorIndex++) { dataFieldCollectionIndex = this.AddMatchingValues(majorHeader, majorIndex, minorIndex, dataFieldCollectionIndex, grandTotalValueLists, grandGrandTotalValueLists); } if (dataFieldCollectionIndex != -1) { this.WriteGrandTotal(majorIndex, grandTotalValueLists); } } return(grandGrandTotalValueLists); }