Esempio n. 1
0
 public ExcelHeaderDecorate()
 {
     _fullName      = "default";
     _type          = "default";
     _chinese       = "未命名";
     _optCode       = 0;
     _canBeEmpty    = false;
     _dataStructure = ECellDataStructure.single;
     _constraint    = null;
     _isStretch     = false;
 }
Esempio n. 2
0
        public bool init(string v_sName, string v_sType, string v_sChinese, int v_col)
        {
            _fullName = v_sName;
            _chinese  = v_sChinese;
            if (string.IsNullOrEmpty(v_sType))
            {
                Debug.Exception("{0}这一列没有写类型名", v_sName);
                return(false);
            }
            string[] types   = v_sType.Split(':');
            string   varType = types[0];

            string[] cons = null;
            if (types.Length == 2 && !string.IsNullOrEmpty(types[1]))
            {
                cons = types[1].Split('|');
            }
            _type = varType;
            if (cons != null && !string.IsNullOrEmpty(cons[0]))
            {
                string         control = cons[0];
                HashSet <char> conSet  = new HashSet <char>();
                foreach (char c in control)
                {
                    conSet.Add(c);
                }
                if (conSet.Contains('a'))
                {
                    _dataStructure = ECellDataStructure.array;
                }
                else
                {
                    _dataStructure = ECellDataStructure.single;
                }
                if (conSet.Contains('<'))
                {
                    _optCode |= 1;
                }
                if (conSet.Contains('>'))
                {
                    _optCode |= 2;
                }
                if (conSet.Contains('e'))
                {
                    _canBeEmpty = true;
                }
                if (conSet.Contains('s'))
                {
                    _isStretch = true;
                }
            }
            _colIndex = v_col;
            return(true);
        }
Esempio n. 3
0
        public CellValue checkData(int v_col, EXCEL.Cell v_cellData)
        {
            ExcelHeaderDecorate ehd = m_header_dct[v_col];
            string             type = ehd.Type;
            ECellDataStructure ds   = ehd.DataStructure;
            CellValue          val  = null;
            object             data = v_cellData.Value;
            bool success            = false;

            if (data == null || string.IsNullOrEmpty(data.ToString()))
            {
                if (!ehd.CanBeEmpty)
                {
                    Debug.Exception("不可为空");
                    return(new MissVal());
                }
            }
            switch (ds)
            {
            case ECellDataStructure.single:
                val     = CellValue.CheckCellVal(ehd);
                success = val.Init(v_cellData, ehd.get_default(), ehd.get_constraint());
                break;

            case ECellDataStructure.array:
                val = new ListVal(type);
                //val.FieldType = type;
                val.IsStretch = ehd.IsStretch;
                success       = val.Init(v_cellData, ehd.get_default(), ehd.get_constraint());
                break;
            }

            if (success)
            {
                val.IsStretch = ehd.IsStretch;
                return(val);
            }
            else
            {
                val     = new MissVal();
                success = val.Init("[nil]");
                Debug.Exception("没有找到名为{0}类型为{1}的ID", v_cellData.Value, type);
                return(null);
            }
        }