/** * 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); }
/** * 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); }
/** * 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()); }
public static CT_PivotField Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) return null; CT_PivotField ctObj = new CT_PivotField(); ctObj.name = XmlHelper.ReadString(node.Attributes["name"]); if (node.Attributes["axis"] != null) ctObj.axis = (ST_Axis)Enum.Parse(typeof(ST_Axis), node.Attributes["axis"].Value); if (node.Attributes["dataField"] != null) ctObj.dataField = XmlHelper.ReadBool(node.Attributes["dataField"]); ctObj.subtotalCaption = XmlHelper.ReadString(node.Attributes["subtotalCaption"]); if (node.Attributes["showDropDowns"] != null) ctObj.showDropDowns = XmlHelper.ReadBool(node.Attributes["showDropDowns"]); if (node.Attributes["hiddenLevel"] != null) ctObj.hiddenLevel = XmlHelper.ReadBool(node.Attributes["hiddenLevel"]); ctObj.uniqueMemberProperty = XmlHelper.ReadString(node.Attributes["uniqueMemberProperty"]); if (node.Attributes["compact"] != null) ctObj.compact = XmlHelper.ReadBool(node.Attributes["compact"]); if (node.Attributes["allDrilled"] != null) ctObj.allDrilled = XmlHelper.ReadBool(node.Attributes["allDrilled"]); if (node.Attributes["numFmtId"] != null) ctObj.numFmtId = XmlHelper.ReadUInt(node.Attributes["numFmtId"]); if (node.Attributes["outline"] != null) ctObj.outline = XmlHelper.ReadBool(node.Attributes["outline"]); if (node.Attributes["subtotalTop"] != null) ctObj.subtotalTop = XmlHelper.ReadBool(node.Attributes["subtotalTop"]); if (node.Attributes["dragToRow"] != null) ctObj.dragToRow = XmlHelper.ReadBool(node.Attributes["dragToRow"]); if (node.Attributes["dragToCol"] != null) ctObj.dragToCol = XmlHelper.ReadBool(node.Attributes["dragToCol"]); if (node.Attributes["multipleItemSelectionAllowed"] != null) ctObj.multipleItemSelectionAllowed = XmlHelper.ReadBool(node.Attributes["multipleItemSelectionAllowed"]); if (node.Attributes["dragToPage"] != null) ctObj.dragToPage = XmlHelper.ReadBool(node.Attributes["dragToPage"]); if (node.Attributes["dragToData"] != null) ctObj.dragToData = XmlHelper.ReadBool(node.Attributes["dragToData"]); if (node.Attributes["dragOff"] != null) ctObj.dragOff = XmlHelper.ReadBool(node.Attributes["dragOff"]); if (node.Attributes["showAll"] != null) ctObj.showAll = XmlHelper.ReadBool(node.Attributes["showAll"]); if (node.Attributes["insertBlankRow"] != null) ctObj.insertBlankRow = XmlHelper.ReadBool(node.Attributes["insertBlankRow"]); if (node.Attributes["serverField"] != null) ctObj.serverField = XmlHelper.ReadBool(node.Attributes["serverField"]); if (node.Attributes["insertPageBreak"] != null) ctObj.insertPageBreak = XmlHelper.ReadBool(node.Attributes["insertPageBreak"]); if (node.Attributes["autoShow"] != null) ctObj.autoShow = XmlHelper.ReadBool(node.Attributes["autoShow"]); if (node.Attributes["topAutoShow"] != null) ctObj.topAutoShow = XmlHelper.ReadBool(node.Attributes["topAutoShow"]); if (node.Attributes["hideNewItems"] != null) ctObj.hideNewItems = XmlHelper.ReadBool(node.Attributes["hideNewItems"]); if (node.Attributes["measureFilter"] != null) ctObj.measureFilter = XmlHelper.ReadBool(node.Attributes["measureFilter"]); if (node.Attributes["includeNewItemsInFilter"] != null) ctObj.includeNewItemsInFilter = XmlHelper.ReadBool(node.Attributes["includeNewItemsInFilter"]); if (node.Attributes["itemPageCount"] != null) ctObj.itemPageCount = XmlHelper.ReadUInt(node.Attributes["itemPageCount"]); if (node.Attributes["sortType"] != null) ctObj.sortType = (ST_FieldSortType)Enum.Parse(typeof(ST_FieldSortType), node.Attributes["sortType"].Value); if (node.Attributes["dataSourceSort"] != null) ctObj.dataSourceSort = XmlHelper.ReadBool(node.Attributes["dataSourceSort"]); if (node.Attributes["nonAutoSortDefault"] != null) ctObj.nonAutoSortDefault = XmlHelper.ReadBool(node.Attributes["nonAutoSortDefault"]); if (node.Attributes["rankBy"] != null) ctObj.rankBy = XmlHelper.ReadUInt(node.Attributes["rankBy"]); if (node.Attributes["defaultSubtotal"] != null) ctObj.defaultSubtotal = XmlHelper.ReadBool(node.Attributes["defaultSubtotal"]); if (node.Attributes["sumSubtotal"] != null) ctObj.sumSubtotal = XmlHelper.ReadBool(node.Attributes["sumSubtotal"]); if (node.Attributes["countASubtotal"] != null) ctObj.countASubtotal = XmlHelper.ReadBool(node.Attributes["countASubtotal"]); if (node.Attributes["avgSubtotal"] != null) ctObj.avgSubtotal = XmlHelper.ReadBool(node.Attributes["avgSubtotal"]); if (node.Attributes["maxSubtotal"] != null) ctObj.maxSubtotal = XmlHelper.ReadBool(node.Attributes["maxSubtotal"]); if (node.Attributes["minSubtotal"] != null) ctObj.minSubtotal = XmlHelper.ReadBool(node.Attributes["minSubtotal"]); if (node.Attributes["productSubtotal"] != null) ctObj.productSubtotal = XmlHelper.ReadBool(node.Attributes["productSubtotal"]); if (node.Attributes["countSubtotal"] != null) ctObj.countSubtotal = XmlHelper.ReadBool(node.Attributes["countSubtotal"]); if (node.Attributes["stdDevSubtotal"] != null) ctObj.stdDevSubtotal = XmlHelper.ReadBool(node.Attributes["stdDevSubtotal"]); if (node.Attributes["stdDevPSubtotal"] != null) ctObj.stdDevPSubtotal = XmlHelper.ReadBool(node.Attributes["stdDevPSubtotal"]); if (node.Attributes["varSubtotal"] != null) ctObj.varSubtotal = XmlHelper.ReadBool(node.Attributes["varSubtotal"]); if (node.Attributes["varPSubtotal"] != null) ctObj.varPSubtotal = XmlHelper.ReadBool(node.Attributes["varPSubtotal"]); if (node.Attributes["showPropCell"] != null) ctObj.showPropCell = XmlHelper.ReadBool(node.Attributes["showPropCell"]); if (node.Attributes["showPropTip"] != null) ctObj.showPropTip = XmlHelper.ReadBool(node.Attributes["showPropTip"]); if (node.Attributes["showPropAsCaption"] != null) ctObj.showPropAsCaption = XmlHelper.ReadBool(node.Attributes["showPropAsCaption"]); if (node.Attributes["defaultAttributeDrillState"] != null) ctObj.defaultAttributeDrillState = XmlHelper.ReadBool(node.Attributes["defaultAttributeDrillState"]); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "items") ctObj.items = CT_Items.Parse(childNode, namespaceManager); else if (childNode.LocalName == "autoSortScope") ctObj.autoSortScope = CT_AutoSortScope.Parse(childNode, namespaceManager); else if (childNode.LocalName == "extLst") ctObj.extLst = CT_ExtensionList.Parse(childNode, namespaceManager); } return ctObj; }
public CT_PivotField AddNewPivotField() { if (this.pivotFieldField == null) this.pivotFieldField = new List<CT_PivotField>(); CT_PivotField f = new CT_PivotField(); this.pivotFieldField.Add(f); return f; }
public void SetPivotFieldArray(int columnIndex, CT_PivotField pivotField) { this.pivotFieldField[columnIndex] = pivotField; }