示例#1
0
        internal void SetCacheFieldNode()
        {
            var groupNode = GetNode("d:fieldGroup");

            if (groupNode != null)
            {
                var groupBy = groupNode.SelectSingleNode("d:rangePr/@groupBy", NameSpaceManager);
                if (groupBy == null)
                {
                    Grouping = new ExcelPivotTableFieldNumericGroup(NameSpaceManager, TopNode);
                }
                else
                {
                    DateGrouping = (eDateGroupBy)Enum.Parse(typeof(eDateGroupBy), groupBy.Value, true);
                    Grouping     = new ExcelPivotTableFieldDateGroup(NameSpaceManager, groupNode);
                }
                AddItems(GroupItems, groupNode.SelectSingleNode("d:groupItems", NameSpaceManager), true);
            }

            var si = GetNode("d:sharedItems");

            if (si != null)
            {
                AddItems(SharedItems, si, groupNode == null);
            }
        }
示例#2
0
        private int AddNumericGroupItems(ExcelPivotTableFieldNumericGroup group, double start, double end, double interval)
        {
            if (interval < 0)
            {
                throw (new Exception("The interval must be a positiv"));
            }
            if (start > end)
            {
                throw(new Exception("Then End number must be larger than the Start number"));
            }

            XmlElement groupItems = group.TopNode.SelectSingleNode("d:fieldGroup/d:groupItems", group.NameSpaceManager) as XmlElement;
            int        items      = 2;
            //First date
            double index     = start;
            double nextIndex = start + interval;

            AddGroupItem(groupItems, "<" + start.ToString(CultureInfo.InvariantCulture));

            while (index < end)
            {
                AddGroupItem(groupItems, string.Format("{0}-{1}", index.ToString(CultureInfo.InvariantCulture), nextIndex.ToString(CultureInfo.InvariantCulture)));
                index      = nextIndex;
                nextIndex += interval;
                items++;
            }
            AddGroupItem(groupItems, ">" + nextIndex.ToString(CultureInfo.InvariantCulture));
            return(items);
        }
示例#3
0
		/// <summary>
		/// Set the numeric group.
		/// </summary>
		/// <param name="start">The start value.</param>
		/// <param name="end">The end value.</param>
		/// <param name="interval">The interval value.</param>
		/// <returns>The new field numeric group.</returns>
		internal ExcelPivotTableFieldNumericGroup SetNumericGroup(double start, double end, double interval)
		{
			ExcelPivotTableFieldNumericGroup group;
			group = new ExcelPivotTableFieldNumericGroup(this.NameSpaceManager, myCacheFieldHelper.TopNode);
			myCacheFieldHelper.SetXmlNodeBool("d:sharedItems/@containsNumber", true);
			myCacheFieldHelper.SetXmlNodeBool("d:sharedItems/@containsInteger", true);
			myCacheFieldHelper.SetXmlNodeBool("d:sharedItems/@containsSemiMixedTypes", false);
			myCacheFieldHelper.SetXmlNodeBool("d:sharedItems/@containsString", false);

			group.TopNode.InnerXml += string.Format("<fieldGroup base=\"{0}\"><rangePr autoStart=\"0\" autoEnd=\"0\" startNum=\"{1}\" endNum=\"{2}\" groupInterval=\"{3}\"/><groupItems /></fieldGroup>", this.BaseIndex, start.ToString(CultureInfo.InvariantCulture), end.ToString(CultureInfo.InvariantCulture), interval.ToString(CultureInfo.InvariantCulture));
			int items = AddNumericGroupItems(group, start, end, interval);
			this.AddFieldItems(items);

			myGrouping = group;
			return group;
		}
        private int AddNumericGroupItems(ExcelPivotTableFieldNumericGroup group, double start, double end, double interval)
        {
            if (interval < 0)
            {
                throw (new Exception("The interval must be a positiv"));
            }
            if (start > end)
            {
                throw(new Exception("Then End number must be larger than the Start number"));
            }

            XmlElement groupItems = group.TopNode.SelectSingleNode("d:fieldGroup/d:groupItems", group.NameSpaceManager) as XmlElement;
            int items = 2;
            //First date
            double index=start;
            double nextIndex=start+interval;
            AddGroupItem(groupItems, "<" + start.ToString(CultureInfo.InvariantCulture));

            while (index < end)
            {
                AddGroupItem(groupItems, string.Format("{0}-{1}", index.ToString(CultureInfo.InvariantCulture), nextIndex.ToString(CultureInfo.InvariantCulture)));
                index=nextIndex;
                nextIndex+=interval;
                items++;
            }
            AddGroupItem(groupItems, ">" + nextIndex.ToString(CultureInfo.InvariantCulture));
            return items;
        }
        internal ExcelPivotTableFieldNumericGroup SetNumericGroup(double start, double end, double interval)
        {
            ExcelPivotTableFieldNumericGroup group;
            group = new ExcelPivotTableFieldNumericGroup(NameSpaceManager, _cacheFieldHelper.TopNode);
            _cacheFieldHelper.SetXmlNodeBool("d:sharedItems/@containsNumber", true);
            _cacheFieldHelper.SetXmlNodeBool("d:sharedItems/@containsInteger", true);
            _cacheFieldHelper.SetXmlNodeBool("d:sharedItems/@containsSemiMixedTypes", false);
            _cacheFieldHelper.SetXmlNodeBool("d:sharedItems/@containsString", false);

            group.TopNode.InnerXml += string.Format("<fieldGroup base=\"{0}\"><rangePr autoStart=\"0\" autoEnd=\"0\" startNum=\"{1}\" endNum=\"{2}\" groupInterval=\"{3}\"/><groupItems /></fieldGroup>", BaseIndex, start.ToString(CultureInfo.InvariantCulture), end.ToString(CultureInfo.InvariantCulture), interval.ToString(CultureInfo.InvariantCulture));
            int items = AddNumericGroupItems(group, start, end, interval);
            AddFieldItems(items);

            _grouping = group;
            return group;
        }