Beispiel #1
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);
        }
Beispiel #2
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)
        {
            AreaReference pivotArea = GetPivotArea();
            int lastRowIndex = pivotArea.LastCell.Row - pivotArea.FirstCell.Row;
            int lastColIndex = pivotArea.LastCell.Col - pivotArea.FirstCell.Col;

            if (columnIndex > lastColIndex)
            {
                throw new IndexOutOfRangeException();
            }
            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());
        }