Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Xml;
|
---|
6 |
|
---|
7 | namespace OfficeOpenXml.Style.Dxf
|
---|
8 | {
|
---|
9 | public class ExcelDxfNumberFormat : DxfStyleBase<ExcelDxfNumberFormat>
|
---|
10 | {
|
---|
11 | public ExcelDxfNumberFormat(ExcelStyles styles) : base(styles)
|
---|
12 | {
|
---|
13 |
|
---|
14 | }
|
---|
15 | int _numFmtID=int.MinValue;
|
---|
16 | /// <summary>
|
---|
17 | /// Id for number format
|
---|
18 | ///
|
---|
19 | /// Build in ID's
|
---|
20 | ///
|
---|
21 | /// 0 General
|
---|
22 | /// 1 0
|
---|
23 | /// 2 0.00
|
---|
24 | /// 3 #,##0
|
---|
25 | /// 4 #,##0.00
|
---|
26 | /// 9 0%
|
---|
27 | /// 10 0.00%
|
---|
28 | /// 11 0.00E+00
|
---|
29 | /// 12 # ?/?
|
---|
30 | /// 13 # ??/??
|
---|
31 | /// 14 mm-dd-yy
|
---|
32 | /// 15 d-mmm-yy
|
---|
33 | /// 16 d-mmm
|
---|
34 | /// 17 mmm-yy
|
---|
35 | /// 18 h:mm AM/PM
|
---|
36 | /// 19 h:mm:ss AM/PM
|
---|
37 | /// 20 h:mm
|
---|
38 | /// 21 h:mm:ss
|
---|
39 | /// 22 m/d/yy h:mm
|
---|
40 | /// 37 #,##0 ;(#,##0)
|
---|
41 | /// 38 #,##0 ;[Red](#,##0)
|
---|
42 | /// 39 #,##0.00;(#,##0.00)
|
---|
43 | /// 40 #,##0.00;[Red](#,##0.00)
|
---|
44 | /// 45 mm:ss
|
---|
45 | /// 46 [h]:mm:ss
|
---|
46 | /// 47 mmss.0
|
---|
47 | /// 48 ##0.0E+0
|
---|
48 | /// 49 @
|
---|
49 | /// </summary>
|
---|
50 | public int NumFmtID
|
---|
51 | {
|
---|
52 | get
|
---|
53 | {
|
---|
54 | return _numFmtID;
|
---|
55 | }
|
---|
56 | internal set
|
---|
57 | {
|
---|
58 | _numFmtID = value;
|
---|
59 | }
|
---|
60 | }
|
---|
61 | string _format="";
|
---|
62 | public string Format
|
---|
63 | {
|
---|
64 | get
|
---|
65 | {
|
---|
66 | return _format;
|
---|
67 | }
|
---|
68 | set
|
---|
69 | {
|
---|
70 | _format = value;
|
---|
71 | NumFmtID = ExcelNumberFormat.GetFromBuildIdFromFormat(value);
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | protected internal override string Id
|
---|
76 | {
|
---|
77 | get
|
---|
78 | {
|
---|
79 | return Format;
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | protected internal override void CreateNodes(XmlHelper helper, string path)
|
---|
84 | {
|
---|
85 | if (NumFmtID < 0 && !string.IsNullOrEmpty(Format))
|
---|
86 | {
|
---|
87 | NumFmtID = _styles._nextDfxNumFmtID++;
|
---|
88 | }
|
---|
89 | helper.CreateNode(path);
|
---|
90 | SetValue(helper, path + "/@numFmtId", NumFmtID);
|
---|
91 | SetValue(helper, path + "/@formatCode", Format);
|
---|
92 | }
|
---|
93 | protected internal override bool HasValue
|
---|
94 | {
|
---|
95 | get
|
---|
96 | {
|
---|
97 | return !string.IsNullOrEmpty(Format);
|
---|
98 | }
|
---|
99 | }
|
---|
100 | protected internal override ExcelDxfNumberFormat Clone()
|
---|
101 | {
|
---|
102 | return new ExcelDxfNumberFormat(_styles) { NumFmtID = NumFmtID, Format = Format };
|
---|
103 | }
|
---|
104 | }
|
---|
105 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.