Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/Style/ExcelNumberFormat.cs @ 10085

Last change on this file since 10085 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: 7.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-16
31 *******************************************************************************/
32using System;
33using System.Collections.Generic;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Globalization;
37
38namespace OfficeOpenXml.Style
39{
40    /// <summary>
41    /// The numberformat of the cell
42    /// </summary>
43    public sealed class ExcelNumberFormat : StyleBase
44    {
45        internal ExcelNumberFormat(ExcelStyles styles, OfficeOpenXml.XmlHelper.ChangedEventHandler ChangedEvent, int PositionID, string Address, int index) :
46            base(styles, ChangedEvent, PositionID, Address)
47        {
48            Index = index;
49        }
50        /// <summary>
51        /// The numeric index fror the format
52        /// </summary>
53        public int NumFmtID
54        {
55            get
56            {
57                return Index;
58            }
59            //set
60            //{
61            //    _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Numberformat, "NumFmtID", value, _workSheetID, _address));
62            //}
63        }
64        /// <summary>
65        /// The numberformat
66        /// </summary>
67        public string Format
68        {
69            get
70            {
71                for(int i=0;i<_styles.NumberFormats.Count;i++)
72                {
73                    if(Index==_styles.NumberFormats[i].NumFmtId)
74                    {
75                        return _styles.NumberFormats[i].Format;
76                    }
77                }
78                return "general";
79            }
80            set
81            {
82                _ChangedEvent(this, new StyleChangeEventArgs(eStyleClass.Numberformat, eStyleProperty.Format, value, _positionID, _address));
83            }
84        }
85
86        internal override string Id
87        {
88            get
89            {
90                return Format;
91            }
92        }
93        /// <summary>
94        /// If the numeric format is a build-in from.
95        /// </summary>
96        public bool BuildIn { get; private set; }
97
98        internal static string GetFromBuildInFromID(int _numFmtId)
99        {
100            switch (_numFmtId)
101            {
102                case 0:
103                    return "General";
104                case 1:
105                    return "0";
106                case 2:
107                    return "0.00";
108                case 3:
109                    return "#,##0";
110                case 4:
111                    return "#,##0.00";
112                case 9:
113                    return "0%";
114                case 10:
115                    return "0.00%";
116                case 11:
117                    return "0.00E+00";
118                case 12:
119                    return "# ?/?";
120                case 13:
121                    return "# ??/??";
122                case 14:
123                    return "mm-dd-yy";
124                case 15:
125                    return "d-mmm-yy";
126                case 16:
127                    return "d-mmm";
128                case 17:
129                    return "mmm-yy";
130                case 18:
131                    return "h:mm AM/PM";
132                case 19:
133                    return "h:mm:ss AM/PM";
134                case 20:
135                    return "h:mm";
136                case 21:
137                    return "h:mm:ss";
138                case 22:
139                    return "m/d/yy h:mm";
140                case 37:
141                    return "#,##0 ;(#,##0)";
142                case 38:
143                    return "#,##0 ;[Red](#,##0)";
144                case 39:
145                    return "#,##0.00;(#,##0.00)";
146                case 40:
147                    return "#,##0.00;[Red](#,#)";
148                case 45:
149                    return "mm:ss";
150                case 46:
151                    return "[h]:mm:ss";
152                case 47:
153                    return "mmss.0";
154                case 48:
155                    return "##0.0";
156                case 49:
157                    return "@";
158                default:
159                    return string.Empty;
160            }
161        }
162        internal static int GetFromBuildIdFromFormat(string format)
163        {
164            switch (format)
165            {
166                case "General":
167                    return 0;
168                case "0":
169                    return 1;
170                case "0.00":
171                    return 2;
172                case "#,##0":
173                    return 3;
174                case "#,##0.00":
175                    return 4;
176                case "0%":
177                    return 9;
178                case "0.00%":
179                    return 10;
180                case "0.00E+00":
181                    return 11;
182                case "# ?/?":
183                    return 12;
184                case "# ??/??":
185                    return 13;
186                case "mm-dd-yy":
187                    return 14;
188                case "d-mmm-yy":
189                    return 15;
190                case "d-mmm":
191                    return 16;
192                case "mmm-yy":
193                    return 17;
194                case "h:mm AM/PM":
195                    return 18;
196                case "h:mm:ss AM/PM":
197                    return 19;
198                case "h:mm":
199                    return 20;
200                case "h:mm:ss":
201                    return 21;
202                case "m/d/yy h:mm":
203                    return 22;
204                case "#,##0 ;(#,##0)":
205                    return 37;
206                case "#,##0 ;[Red](#,##0)":
207                    return 38;
208                case "#,##0.00;(#,##0.00)":
209                    return 39;
210                case "#,##0.00;[Red](#,#)":
211                    return 40;
212                case "mm:ss":
213                    return 45;
214                case "[h]:mm:ss":
215                    return 46;
216                case "mmss.0":
217                    return 47;
218                case "##0.0":
219                    return 48;
220                case "@":
221                    return 49;
222                default:
223                    return int.MinValue;
224            }
225        }
226    }
227}
Note: See TracBrowser for help on using the repository browser.