Esempio n. 1
0
        private void WritePivotTableBodyData(PivotCellBackingData[,] backingDatas,
                                             List <PivotCellBackingData> columnGrandTotalsValuesLists, List <PivotCellBackingData> rowGrandTotalsValuesLists,
                                             PivotCellBackingData[] grandGrandTotalValues, TotalsFunctionHelper totalsCalculator)
        {
            int sheetColumn = this.PivotTable.Address.Start.Column + this.PivotTable.FirstDataCol;

            for (int column = 0; column < this.PivotTable.ColumnHeaders.Count; column++)
            {
                var columnHeader = this.PivotTable.ColumnHeaders[column];
                int sheetRow     = this.PivotTable.Address.Start.Row + this.PivotTable.FirstDataRow - 1;
                for (int row = 0; row < this.PivotTable.RowHeaders.Count; row++)
                {
                    sheetRow++;
                    var rowHeader = this.PivotTable.RowHeaders[row];
                    if (rowHeader.IsGrandTotal || columnHeader.IsGrandTotal || !backingDatas[row, column].ShowValue)
                    {
                        continue;
                    }

                    var dataFieldCollectionIndex = this.PivotTable.HasRowDataFields ? rowHeader.DataFieldCollectionIndex : columnHeader.DataFieldCollectionIndex;
                    var dataField            = this.PivotTable.DataFields[dataFieldCollectionIndex];
                    var showDataAsCalculator = ShowDataAsFactory.GetShowDataAsCalculator(dataField.ShowDataAs, this.PivotTable, dataFieldCollectionIndex, this.TotalsCalculator);
                    var value = showDataAsCalculator.CalculateBodyValue(
                        row, column,
                        backingDatas,
                        grandGrandTotalValues,
                        rowGrandTotalsValuesLists,
                        columnGrandTotalsValuesLists);

                    var cell = this.PivotTable.Worksheet.Cells[sheetRow, sheetColumn];
                    this.WriteCellValue(value, cell, dataField, this.PivotTable.Workbook.Styles);
                }
                sheetColumn++;
            }
        }
Esempio n. 2
0
        private void WriteGrandTotalValues(bool isRowTotal, List <PivotCellBackingData> grandTotalsBackingDatas, PivotCellBackingData[] columnGrandGrandTotalValues)
        {
            for (int i = 0; i < grandTotalsBackingDatas.Count; i++)
            {
                var grandTotalBackingData = grandTotalsBackingDatas[i];
                if (grandTotalBackingData == null || !grandTotalBackingData.ShowValue)
                {
                    continue;
                }
                var dataField = this.PivotTable.DataFields[grandTotalBackingData.DataFieldCollectionIndex];

                var showDataAsCalculator = ShowDataAsFactory.GetShowDataAsCalculator(dataField.ShowDataAs, this.PivotTable, grandTotalBackingData.DataFieldCollectionIndex, this.TotalsCalculator);
                var value = showDataAsCalculator.CalculateGrandTotalValue(i, grandTotalsBackingDatas, columnGrandGrandTotalValues, isRowTotal);

                var cell = this.PivotTable.Worksheet.Cells[grandTotalBackingData.SheetRow, grandTotalBackingData.SheetColumn];
                this.WriteCellValue(value, cell, dataField, this.PivotTable.Workbook.Styles);
            }
        }
Esempio n. 3
0
        private void WriteGrandGrandTotals(PivotCellBackingData[] columnGrandGrandTotalsLists)
        {
            var styles = this.PivotTable.Workbook.Styles;

            foreach (var backingData in columnGrandGrandTotalsLists)
            {
                if (backingData == null)
                {
                    continue;
                }
                var dataField = this.PivotTable.DataFields[backingData.DataFieldCollectionIndex];

                var showDataAsCalculator = ShowDataAsFactory.GetShowDataAsCalculator(dataField.ShowDataAs, this.PivotTable, backingData.DataFieldCollectionIndex, this.TotalsCalculator);
                var value = showDataAsCalculator.CalculateGrandGrandTotalValue(backingData);

                var cell = this.PivotTable.Worksheet.Cells[backingData.SheetRow, backingData.SheetColumn];
                this.WriteCellValue(value, cell, dataField, styles);
            }
        }