示例#1
0
        public Column(DataView dataView, SheetView sheetView, int colNum)
        {
            ColumnNum = colNum;
            var sheetColumn = sheetView.GetColumn(colNum);

            Name             = sheetColumn[2];
            ColumnTypeString = sheetColumn[4];
            try
            {
                ColumnType = dataView.ColumnTypeParser.ParseColumnType(ColumnTypeString, Name);
            }
            catch (Exception e)
            {
                throw new Exception($"类型{ColumnTypeString}解析失败", e);
            }
            ConfigTypes  = Utils.ParseConfigTypes(sheetColumn[5]);
            DefaultValue = sheetColumn[3] == "" ? ColumnType.DefaultValue : sheetColumn[3];
            //ID检查
            if (colNum == 1)
            {
                if (Name != "Id")
                {
                    throw new Exception("表中第一列名称必须为Id!");
                }
                if (!(ColumnType is IIdColumnType))
                {
                    throw new Exception("表中第一列类型必须为Id类型!");
                }
            }
        }
示例#2
0
文件: DataView.cs 项目: taigacon/ET
        private Tuple <List <Column>, Dictionary <string, Column> > ReadHeader(SheetView sheetView)
        {
            try
            {
                List <Column> columns = new List <Column>();
                for (int i = 1; i <= sheetView.MaxColumn; i++)
                {
                    if (sheetView.IsStopColumn(i, 0))
                    {
                        break;
                    }
                    Column column;
                    try
                    {
                        column = new Column(this, sheetView, i);
                    }
                    catch (Exception e)
                    {
                        throw new Exception($"{e.Message}\n处理列{Utils.ColumnNum2Label(i)}失败", e);
                    }
                    columns.Add(column);
                }
                Dictionary <string, Column> columnsDic = new Dictionary <string, Column>();
                foreach (var column in columns)
                {
                    if (columnsDic.ContainsKey(column.Name))
                    {
                        throw new Exception($"列{column.ColumnNum}和{columnsDic[column.Name].ColumnNum}有重复的键名{column.Name}");
                    }
                    columnsDic.Add(column.Name, column);
                }

                return(new Tuple <List <Column>, Dictionary <string, Column> >(columns, columnsDic));
            }
            catch (Exception e)
            {
                throw new Exception($"{e.Message}\n处理表{sheetView.Name}失败", e);
            }
        }
示例#3
0
文件: SheetView.cs 项目: taigacon/ET
 public Column(SheetView sv, int columnNumber)
 {
     this.sv           = sv;
     this.columnNumber = columnNumber;
 }
示例#4
0
文件: SheetView.cs 项目: taigacon/ET
 public Rows(SheetView sv, int startRow, int endRow)
 {
     this.sv       = sv;
     this.startRow = startRow;
     this.endRow   = endRow;
 }
示例#5
0
文件: SheetView.cs 项目: taigacon/ET
 public Row(SheetView sv, int rowNum)
 {
     this.sv     = sv;
     this.rowNum = rowNum;
 }