Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ExportSymbolicDataAnalysisSolutions/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/ExcelProtectedRangeCollection.cs @ 9580

Last change on this file since 9580 was 9580, checked in by sforsten, 11 years ago

#1730:

  • added SymbolicDataAnalysisExpressionExcelFormatter
  • changed modifiers in SymbolicExpressionTreeChart of methods SaveImageAsBitmap and SaveImageAsEmf to public
  • added menu item ExportSymbolicSolutionToExcelMenuItem to export a symbolic solution to an excel file
  • added EPPlus-3.1.3 to ExtLibs
File size: 3.0 KB
Line 
1using OfficeOpenXml.Utils;
2using System;
3using System.Collections.Generic;
4using System.Collections.ObjectModel;
5using System.Linq;
6using System.Text;
7using System.Xml;
8
9namespace OfficeOpenXml
10{
11    public class ExcelProtectedRangeCollection : XmlHelper, IEnumerable<ExcelProtectedRange>
12    {
13        internal ExcelProtectedRangeCollection(XmlNamespaceManager nsm, XmlNode topNode, ExcelWorksheet ws)
14            : base(nsm, topNode)
15        {
16            foreach (XmlNode protectedRangeNode in topNode.SelectNodes("d:protectedRanges/d:protectedRange", nsm))
17            {
18                if (!(protectedRangeNode is XmlElement))
19                    continue;
20                _baseList.Add(new ExcelProtectedRange(protectedRangeNode.Attributes["name"].Value, new ExcelAddress(SqRefUtility.FromSqRefAddress(protectedRangeNode.Attributes["sqref"].Value)), nsm, topNode));
21            }
22        }
23
24        private List<ExcelProtectedRange> _baseList = new List<ExcelProtectedRange>();
25
26        public ExcelProtectedRange Add(string name, ExcelAddress address)
27        {
28            if (!ExistNode("d:protectedRanges"))
29                CreateNode("d:protectedRanges");
30           
31            var newNode = CreateNode("d:protectedRanges/d:protectedRange");
32            var item = new ExcelProtectedRange(name, address, base.NameSpaceManager, newNode);
33            _baseList.Add(item);
34            return item;
35        }
36
37        public void Clear()
38        {
39            DeleteNode("d:protectedRanges");
40            _baseList.Clear();
41        }
42
43        public bool Contains(ExcelProtectedRange item)
44        {
45            return _baseList.Contains(item);
46        }
47
48        public void CopyTo(ExcelProtectedRange[] array, int arrayIndex)
49        {
50            _baseList.CopyTo(array, arrayIndex);
51        }
52
53        public int Count
54        {
55            get { return _baseList.Count; }
56        }
57
58        public bool Remove(ExcelProtectedRange item)
59        {
60            DeleteAllNode("d:protectedRanges/d:protectedRange[@name='" + item.Name + "' and @sqref='" + item.Address.Address + "']");
61            if (_baseList.Count == 0)
62                DeleteNode("d:protectedRanges");
63            return _baseList.Remove(item);
64        }
65
66        public int IndexOf(ExcelProtectedRange item)
67        {
68            return _baseList.IndexOf(item);
69        }
70
71        public void RemoveAt(int index)
72        {
73            _baseList.RemoveAt(index);
74        }
75
76        public ExcelProtectedRange this[int index]
77        {
78            get
79            {
80                return _baseList[index];
81            }
82        }
83
84        IEnumerator<ExcelProtectedRange> IEnumerable<ExcelProtectedRange>.GetEnumerator()
85        {
86            return _baseList.GetEnumerator();
87        }
88
89        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
90        {
91            return _baseList.GetEnumerator();
92        }
93    }
94}
Note: See TracBrowser for help on using the repository browser.