OfficeOpenXml.Table.PivotTable.ExcelPivotTableField.AddNumericGroupItems C# (CSharp) Method

AddNumericGroupItems() private method

private AddNumericGroupItems ( OfficeOpenXml.Table.PivotTable.ExcelPivotTableFieldNumericGroup group, double start, double end, double interval ) : int
group OfficeOpenXml.Table.PivotTable.ExcelPivotTableFieldNumericGroup
start double
end double
interval double
return int
        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;
        }