Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/ExcelStyleCollection.cs @ 10187

Last change on this file since 10187 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: 4.6 KB
Line 
1/*******************************************************************************
2 * You may amend and distribute as you like, but don't remove this header!
3 *
4 * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets.
5 * See http://www.codeplex.com/EPPlus for details.
6 *
7 * Copyright (C) 2011  Jan Källman
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
17 * See the GNU Lesser General Public License for more details.
18 *
19 * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
20 * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
21 *
22 * All code and executables are provided "as is" with no warranty either express or implied.
23 * The author accepts no liability for any damage or loss of business that this product may cause.
24 *
25 * Code change notes:
26 *
27 * Author             Change            Date
28 * ******************************************************************************
29 * Jan Källman        Initial Release           2009-10-01
30 * Jan Källman        License changed GPL-->LGPL 2011-12-27
31 *******************************************************************************/
32using System;
33using System.Collections.Generic;
34using System.Text;
35using System.Xml;
36namespace OfficeOpenXml
37{
38    /// <summary>
39    /// Base collection class for styles.
40    /// </summary>
41    /// <typeparam name="T">The style type</typeparam>
42    public class ExcelStyleCollection<T> : IEnumerable<T>
43    {
44        public ExcelStyleCollection()
45        {
46            _setNextIdManual = false;
47        }
48        bool _setNextIdManual;
49        public ExcelStyleCollection(bool SetNextIdManual)
50        {
51            _setNextIdManual = SetNextIdManual;
52        }
53        public XmlNode TopNode { get; set; }
54        internal List<T> _list = new List<T>();
55        Dictionary<string, int> _dic = new Dictionary<string, int>();
56        internal int NextId=0;
57        #region IEnumerable<T> Members
58
59        public IEnumerator<T> GetEnumerator()
60        {
61            return _list.GetEnumerator();
62        }
63
64        #endregion
65        #region IEnumerable Members
66
67        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
68        {
69            return _list.GetEnumerator();
70        }
71        #endregion
72        public T this[int PositionID]
73        {
74            get
75            {
76                return _list[PositionID];
77            }
78        }
79        public int Count
80        {
81            get
82            {
83                return _list.Count;
84            }
85        }
86        //internal int Add(T item)
87        //{
88        //    _list.Add(item);
89        //    if (_setNextIdManual) NextId++;
90        //    return _list.Count-1;
91        //}
92        internal int Add(string key, T item)
93        {
94            _list.Add(item);
95            if (!_dic.ContainsKey(key.ToLower())) _dic.Add(key.ToLower(), _list.Count - 1);
96            if (_setNextIdManual) NextId++;
97            return _list.Count-1;
98        }
99        /// <summary>
100        /// Finds the key
101        /// </summary>
102        /// <param name="key">the key to be found</param>
103        /// <param name="obj">The found object.</param>
104        /// <returns>True if found</returns>
105        internal bool FindByID(string key, ref T obj)
106        {
107            if (_dic.ContainsKey(key.ToLower()))
108            {
109                obj = _list[_dic[key.ToLower()]];
110                return true;
111            }
112            else
113            {
114                return false;
115            }
116        }
117        /// <summary>
118        /// Find Index
119        /// </summary>
120        /// <param name="key"></param>
121        /// <returns></returns>
122        internal int FindIndexByID(string key)
123        {
124            if (_dic.ContainsKey(key.ToLower()))
125            {
126                return _dic[key.ToLower()];
127            }
128            else
129            {
130                return int.MinValue;
131            }
132        }
133        internal bool ExistsKey(string key)
134        {
135            return _dic.ContainsKey(key.ToLower());
136        }
137        internal void Sort(Comparison<T> c)
138        {
139            _list.Sort(c);
140        }
141    }
142}
Note: See TracBrowser for help on using the repository browser.