public ExcelConfig GetExcelConfig(string templatePath) { var config = new ExcelConfig(templatePath); Workbook workbook = new Workbook(new MemoryStream(config.Metadata.FileBuffer)); for (int k = 0; k < workbook.Worksheets.Count; k++) { var cells = workbook.Worksheets[k].Cells; var comments = workbook.Worksheets[k].Comments; var table = new TableConfig(); config.Tables.Add(table); table.TableName = workbook.Worksheets[k].Name; //if (GlobalData.TableConfigDic.ContainsKey(table.TableName)) // GlobalData.TableConfigDic[table.TableName] = table; //else // GlobalData.TableConfigDic.Add(table.TableName, table); //循环行 for (int i = 0; i < cells.MaxDataRow + 1; i++) { // 循环列 for (int j = 0; j < cells.MaxDataColumn + 1; j++) { string s = cells[i, j].StringValue.Trim(); var fieldName = ParseFieldName(s); if (!string.IsNullOrWhiteSpace(fieldName)) { table.StartRowIndex = i; table.StartColIndex = j; var note = string.Empty; var comment = comments[i, j]; if (comment != null) { note = comment.Note; } var cellConfig = GetCellInfo(s, i, j, note); table.Cells.Add(cellConfig); table.FieldNames.Add(cellConfig.FieldName); } } } } return(config); }
public ExcelTableInfo(TableConfig config) { this.Structure = config; Rows = new List <ExcelRowInfo>(); }