Beispiel #1
0
 public static object ParseExcelType(string str, string type)
 {
     if (INT.Equals(type))
     {
         if (string.IsNullOrEmpty(str))
         {
             return(0);
         }
         return(int.Parse(str));
     }
     else if (NUMBER.Equals(type))
     {
         if (string.IsNullOrEmpty(str))
         {
             return(0);
         }
         return(LockStepConst.ParseInLevelInt(str));
     }
     else if (FLOAT.Equals(type))
     {
         if (string.IsNullOrEmpty(str))
         {
             return(0);
         }
         return(float.Parse(str));
     }
     else if (STRING.Equals(type))
     {
         return(str);
     }
     else if (BOOL.Equals(type))
     {
         return("true".Equals(str.ToLower()));
     }
     else if (LINT.Equals(type))
     {
         string[]   p      = str.SplitStringBySplits();
         List <int> result = new List <int>(p.Length);
         for (int i = 0; i < p.Length; i++)
         {
             if (string.IsNullOrEmpty(str))
             {
                 result.Add(0);
             }
             else
             {
                 result.Add(int.Parse(p[i]));
             }
         }
         return(result);
     }
     else if (LNUMBER.Equals(type))
     {
         string[]   p      = str.SplitStringBySplits();
         List <int> result = new List <int>(p.Length);
         for (int i = 0; i < p.Length; i++)
         {
             if (string.IsNullOrEmpty(str))
             {
                 result.Add(0);
             }
             else
             {
                 result.Add(LockStepConst.ParseInLevelInt(p[i]));
             }
         }
         return(result);
     }
     else if (LFLOAT.Equals(type))
     {
         string[]     p      = str.SplitStringBySplits();
         List <float> result = new List <float>(p.Length);
         for (int i = 0; i < p.Length; i++)
         {
             if (string.IsNullOrEmpty(str))
             {
                 result.Add(0);
             }
             else
             {
                 result.Add(float.Parse(p[i]));
             }
         }
         return(result);
     }
     else if (LSTRING.Equals(type))
     {
         string[]      p      = str.SplitStringBySplits();
         List <string> result = new List <string>(p.Length);
         for (int i = 0; i < p.Length; i++)
         {
             result.Add(p[i]);
         }
         return(result);
     }
     else if (LBOOL.Equals(type))
     {
         string[]    p      = str.SplitStringBySplits();
         List <bool> result = new List <bool>(p.Length);
         for (int i = 0; i < p.Length; i++)
         {
             result.Add("true".Equals(str));
         }
         return(result);
     }
     return(null);
 }