Ejemplo n.º 1
0
        /**
         * Add a row label using data from the given column.
         * @param columnIndex the index of the column to be used as row label.
         */

        public void AddRowLabel(int columnIndex)
        {
            CheckColumnIndex(columnIndex);
            AreaReference pivotArea    = GetPivotArea();
            int           lastRowIndex = pivotArea.LastCell.Row - pivotArea.FirstCell.Row;

            CT_PivotFields pivotFields = pivotTableDefinition.pivotFields;

            CT_PivotField pivotField = new CT_PivotField();
            CT_Items      items      = pivotField.AddNewItems();

            pivotField.axis    = (/*setter*/ ST_Axis.axisRow);
            pivotField.showAll = (/*setter*/ false);
            for (int i = 0; i <= lastRowIndex; i++)
            {
                items.AddNewItem().t = (/*setter*/ ST_ItemType.@default);
            }
            items.count = (/*setter*/ items.SizeOfItemArray());
            pivotFields.SetPivotFieldArray(columnIndex, pivotField);

            CT_RowFields rowFields;

            if (pivotTableDefinition.rowFields != null)
            {
                rowFields = pivotTableDefinition.rowFields;
            }
            else
            {
                rowFields = pivotTableDefinition.AddNewRowFields();
            }

            rowFields.AddNewField().x = (/*setter*/ columnIndex);
            rowFields.count = (/*setter*/ rowFields.SizeOfFieldArray());
        }
Ejemplo n.º 2
0
        public void TestAddDataColumn()
        {
            int  columnIndex = 0;
            bool isDataField = true;

            pivotTable.AddDataColumn(columnIndex, isDataField);
            CT_PivotFields pivotFields = pivotTable.GetCTPivotTableDefinition().pivotFields;

            Assert.AreEqual(pivotFields.GetPivotFieldArray(columnIndex).dataField, isDataField);
        }
Ejemplo n.º 3
0
        /**
         * Add column Containing data from the referenced area.
         * @param columnIndex the index of the column Containing the data
         * @param isDataField true if the data should be displayed in the pivot table.
         */

        public void AddDataColumn(int columnIndex, bool isDataField)
        {
            CheckColumnIndex(columnIndex);

            CT_PivotFields pivotFields = pivotTableDefinition.pivotFields;
            CT_PivotField  pivotField  = new CT_PivotField();

            pivotField.dataField = (/*setter*/ isDataField);
            pivotField.showAll   = (/*setter*/ false);
            pivotFields.SetPivotFieldArray(columnIndex, pivotField);
        }
Ejemplo n.º 4
0
        /**
         * Add column Containing data from the referenced area.
         * @param columnIndex the index of the column Containing the data
         * @param isDataField true if the data should be displayed in the pivot table.
         */

        public void AddDataColumn(int columnIndex, bool isDataField)
        {
            AreaReference pivotArea    = GetPivotArea();
            int           lastColIndex = pivotArea.LastCell.Col - pivotArea.FirstCell.Col;

            if (columnIndex > lastColIndex && columnIndex < 0)
            {
                throw new IndexOutOfRangeException();
            }
            CT_PivotFields pivotFields = pivotTableDefinition.pivotFields;
            CT_PivotField  pivotField  = new CT_PivotField();

            pivotField.dataField = (/*setter*/ isDataField);
            pivotField.showAll   = (/*setter*/ false);
            pivotFields.SetPivotFieldArray(columnIndex, pivotField);
        }
Ejemplo n.º 5
0
        /**
         * Add filter for the column with the corresponding index and cell value
         * @param columnIndex index of column to filter on
         */

        public void AddReportFilter(int columnIndex)
        {
            AreaReference pivotArea    = GetPivotArea();
            int           lastColIndex = pivotArea.LastCell.Col - pivotArea.FirstCell.Col;
            int           lastRowIndex = pivotArea.LastCell.Row - pivotArea.FirstCell.Row;

            if (columnIndex > lastColIndex && columnIndex < 0)
            {
                throw new IndexOutOfRangeException();
            }
            CT_PivotFields pivotFields = pivotTableDefinition.pivotFields;

            CT_PivotField pivotField = new CT_PivotField();
            CT_Items      items      = pivotField.AddNewItems();

            pivotField.axis    = (/*setter*/ ST_Axis.axisPage);
            pivotField.showAll = (/*setter*/ false);
            for (int i = 0; i <= lastRowIndex; i++)
            {
                items.AddNewItem().t = (/*setter*/ ST_ItemType.@default);
            }
            items.count = (/*setter*/ items.SizeOfItemArray());
            pivotFields.SetPivotFieldArray(columnIndex, pivotField);

            CT_PageFields pageFields;

            if (pivotTableDefinition.pageFields != null)
            {
                pageFields = pivotTableDefinition.pageFields;
                //Another filter has already been Created
                pivotTableDefinition.multipleFieldFilters = (/*setter*/ true);
            }
            else
            {
                pageFields = pivotTableDefinition.AddNewPageFields();
            }
            CT_PageField pageField = pageFields.AddNewPageField();

            pageField.hier = (/*setter*/ -1);
            pageField.fld  = (/*setter*/ columnIndex);

            pageFields.count = (/*setter*/ pageFields.SizeOfPageFieldArray());
            pivotTableDefinition.location.colPageCount = (/*setter*/ pageFields.count);
        }