Esempio n. 1
0
        /**
         * Add a column label using data from the given column and specified function
         * @param columnIndex the index of the column to be used as column label.
         * @param function the function to be used on the data
         * The following functions exists:
         * Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp
         */

        public void AddColumnLabel(DataConsolidateFunction function, int columnIndex)
        {
            AddColumnLabel(function, columnIndex, function.Name);
        }
Esempio n. 2
0
        /**
         * Add data field with data from the given column and specified function.
         * @param function the function to be used on the data
         * @param index the index of the column to be used as column label.
         * The following functions exists:
         * Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp
         * @param valueFieldName the name of pivot table value field
         */

        private void AddDataField(DataConsolidateFunction function, int columnIndex, String valueFieldName)
        {
            AreaReference pivotArea = GetPivotArea();
            int lastColIndex = pivotArea.LastCell.Col - pivotArea.FirstCell.Col;

            if (columnIndex > lastColIndex && columnIndex < 0)
            {
                throw new IndexOutOfRangeException();
            }
            CT_DataFields dataFields;
            if (pivotTableDefinition.dataFields != null)
            {
                dataFields = pivotTableDefinition.dataFields;
            }
            else
            {
                dataFields = pivotTableDefinition.AddNewDataFields();
            }
            CT_DataField dataField = dataFields.AddNewDataField();
            dataField.subtotal = (ST_DataConsolidateFunction)(function.Value);
            ICell cell = GetDataSheet().GetRow(pivotArea.FirstCell.Row).GetCell(columnIndex);
            cell.SetCellType(CellType.String);
            dataField.name = (/*setter*/valueFieldName);
            dataField.fld = (uint)columnIndex;
            dataFields.count = (/*setter*/dataFields.SizeOfDataFieldArray());
        }
Esempio n. 3
0
        /**
         * Add a column label using data from the given column and specified function
         * @param columnIndex the index of the column to be used as column label.
         * @param function the function to be used on the data
         * The following functions exists:
         * Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp
         * @param valueFieldName the name of pivot table value field
         */

        public void AddColumnLabel(DataConsolidateFunction function, int columnIndex, String valueFieldName)
        {
            AreaReference pivotArea = GetPivotArea();
            int lastColIndex = pivotArea.LastCell.Col - pivotArea.FirstCell.Col;

            if (columnIndex > lastColIndex && columnIndex < 0)
            {
                throw new IndexOutOfRangeException();
            }

            AddDataColumn(columnIndex, true);
            AddDataField(function, columnIndex, valueFieldName);

            // colfield should be Added for the second one.
            if (pivotTableDefinition.dataFields.count == 2)
            {
                CT_ColFields colFields;
                if (pivotTableDefinition.colFields != null)
                {
                    colFields = pivotTableDefinition.colFields;
                }
                else
                {
                    colFields = pivotTableDefinition.AddNewColFields();
                }
                colFields.AddNewField().x = (/*setter*/-2);
                colFields.count = (/*setter*/colFields.SizeOfFieldArray());
            }
        }