Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ExcelParser Class Reference

Static Public Member Functions

static bool IsNull (ICell cell)
 
static int GetInt (int id)
 
static int GetInt (int col, IRow _row)
 
static bool GetBool (int id)
 
static bool GetBool (int col, IRow _row)
 
static double GetDouble (int id)
 
static float GetFloat (int id)
 
static float[] GetFloatArray (int id)
 
static int[] GetIntArray (int id)
 
static string[] GetStringArray (int id)
 
static string GetString (int id)
 
static string GetString (int col, IRow _row)
 
static string GetStr (int id, bool useDefault=false)
 

Static Public Attributes

static IRow row
 
static IRow rowDefault
 

Detailed Description

Definition at line 4 of file ExcelParser.cs.

Member Function Documentation

◆ GetBool() [1/2]

static bool ExcelParser.GetBool ( int  col,
IRow  _row 
)
inlinestatic

Definition at line 46 of file ExcelParser.cs.

47 {
48 row = _row;
49 return GetBool(col);
50 }
static bool GetBool(int id)
Definition: ExcelParser.cs:34
static IRow row
Definition: ExcelParser.cs:6

References GetBool(), and row.

◆ GetBool() [2/2]

static bool ExcelParser.GetBool ( int  id)
inlinestatic

Definition at line 34 of file ExcelParser.cs.

35 {
36 string str = GetStr(id);
37 return str switch
38 {
39 "0" => false,
40 "1" => true,
41 null => false,
42 _ => bool.Parse(str),
43 };
44 }
static string GetStr(int id, bool useDefault=false)
Definition: ExcelParser.cs:113

References GetStr().

Referenced by GetBool(), SourceData< T, T2 >.GetBool(), and TextConv.Item.Item().

◆ GetDouble()

static double ExcelParser.GetDouble ( int  id)
inlinestatic

Definition at line 52 of file ExcelParser.cs.

53 {
54 string str = GetStr(id);
55 if (str != null)
56 {
57 return double.Parse(str);
58 }
59 return 0.0;
60 }

References GetStr().

Referenced by SourceData< T, T2 >.GetDouble().

◆ GetFloat()

static float ExcelParser.GetFloat ( int  id)
inlinestatic

Definition at line 62 of file ExcelParser.cs.

63 {
64 string str = GetStr(id);
65 if (str != null)
66 {
67 return float.Parse(str);
68 }
69 return 0f;
70 }

References GetStr().

Referenced by SourceData< T, T2 >.GetFloat().

◆ GetFloatArray()

static float[] ExcelParser.GetFloatArray ( int  id)
inlinestatic

Definition at line 72 of file ExcelParser.cs.

73 {
74 string str = GetStr(id);
75 if (str != null)
76 {
77 return Array.ConvertAll(str.Split(','), float.Parse);
78 }
79 return new float[0];
80 }

References GetStr().

Referenced by SourceData< T, T2 >.GetFloatArray().

◆ GetInt() [1/2]

static int ExcelParser.GetInt ( int  col,
IRow  _row 
)
inlinestatic

Definition at line 28 of file ExcelParser.cs.

29 {
30 row = _row;
31 return GetInt(col);
32 }
static int GetInt(int id)
Definition: ExcelParser.cs:19

References GetInt(), and row.

◆ GetInt() [2/2]

static int ExcelParser.GetInt ( int  id)
inlinestatic

Definition at line 19 of file ExcelParser.cs.

20 {
21 if (int.TryParse(GetStr(id), out var result))
22 {
23 return result;
24 }
25 return 0;
26 }

References GetStr().

Referenced by TextConv.BuildMap(), GetInt(), and SourceData< T, T2 >.GetInt().

◆ GetIntArray()

static int[] ExcelParser.GetIntArray ( int  id)
inlinestatic

Definition at line 82 of file ExcelParser.cs.

83 {
84 string str = GetStr(id);
85 if (str != null)
86 {
87 return Array.ConvertAll(str.Split(','), int.Parse);
88 }
89 return new int[0];
90 }

References GetStr().

Referenced by SourceData< T, T2 >.GetIntArray().

◆ GetStr()

static string ExcelParser.GetStr ( int  id,
bool  useDefault = false 
)
inlinestatic

Definition at line 113 of file ExcelParser.cs.

114 {
115 IRow row = (useDefault ? rowDefault : ExcelParser.row);
116 if (row == null)
117 {
118 if (!useDefault)
119 {
120 return GetStr(id, useDefault: true);
121 }
122 return null;
123 }
124 ICell cell = row.GetCell(id);
125 if (IsNull(cell))
126 {
127 if (!useDefault)
128 {
129 return GetStr(id, useDefault: true);
130 }
131 return null;
132 }
133 cell.SetCellType(CellType.String);
134 if (cell.StringCellValue == "")
135 {
136 if (!useDefault)
137 {
138 return GetStr(id, useDefault: true);
139 }
140 return null;
141 }
142 return cell.StringCellValue;
143 }
static IRow rowDefault
Definition: ExcelParser.cs:8
static bool IsNull(ICell cell)
Definition: ExcelParser.cs:10

References GetStr(), IsNull(), row, and rowDefault.

Referenced by GetBool(), GetDouble(), GetFloat(), GetFloatArray(), GetInt(), GetIntArray(), GetStr(), SourceData< T, T2 >.GetStr(), GetString(), and GetStringArray().

◆ GetString() [1/2]

static string ExcelParser.GetString ( int  col,
IRow  _row 
)
inlinestatic

Definition at line 107 of file ExcelParser.cs.

108 {
109 row = _row;
110 return GetStr(col);
111 }

References GetStr(), and row.

◆ GetString() [2/2]

static string ExcelParser.GetString ( int  id)
inlinestatic

Definition at line 102 of file ExcelParser.cs.

103 {
104 return GetStr(id) ?? "";
105 }

References GetStr().

Referenced by SourceData< T, T2 >.GetString(), and ExcelData.Override().

◆ GetStringArray()

static string[] ExcelParser.GetStringArray ( int  id)
inlinestatic

Definition at line 92 of file ExcelParser.cs.

93 {
94 string str = GetStr(id);
95 if (str != null)
96 {
97 return str.Split(',');
98 }
99 return new string[0];
100 }

References GetStr().

Referenced by SourceData< T, T2 >.GetStringArray().

◆ IsNull()

static bool ExcelParser.IsNull ( ICell  cell)
inlinestatic

Definition at line 10 of file ExcelParser.cs.

11 {
12 if (cell != null && cell.CellType != CellType.Blank)
13 {
14 return cell.CellType == CellType.Unknown;
15 }
16 return true;
17 }

Referenced by GetStr().

Member Data Documentation

◆ row

IRow ExcelParser.row
static

Definition at line 6 of file ExcelParser.cs.

Referenced by GetBool(), GetInt(), GetStr(), and GetString().

◆ rowDefault

IRow ExcelParser.rowDefault
static

Definition at line 8 of file ExcelParser.cs.

Referenced by GetStr().


The documentation for this class was generated from the following file: