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类型!"); } } }
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); } }
public Column(SheetView sv, int columnNumber) { this.sv = sv; this.columnNumber = columnNumber; }
public Rows(SheetView sv, int startRow, int endRow) { this.sv = sv; this.startRow = startRow; this.endRow = endRow; }
public Row(SheetView sv, int rowNum) { this.sv = sv; this.rowNum = rowNum; }