/// <summary> /// 解析配置 /// </summary> public void ResolveConfig() { // 重置填充单元格的行号 Fill.ForEach(t => { t.RowIndex--; t.ColumnIndex = PowerExcelConfigCell.ToIndex(t.Col); }); //设置整体属性 Prop.StartColumnIndex = PowerExcelConfigCell.ToIndex(Prop.StartCol); Prop.DemoRow--; Prop.StartRow = Prop.DemoRow + 1; //设置循环列的 列索引号 var i = 0; Row.ForEach(field => { field.ColumnIndex = Prop.StartColumnIndex + i++; field.Col = field.GetColumnChar(); }); //设置列的公式信息 将$Field转换成 D{i} Row.Where(t => string.IsNullOrEmpty(t.Formula) == false).ToList().ForEach(field => { field.Formula = Regex.Replace(field.Formula, @"\$(?<name>\w+)", (match) => { var name = match.Groups["name"]?.Value; if (string.IsNullOrEmpty(name)) { return(match.Value); } //查找源字段 得到公式信息 var index = Row.FirstOrDefault(t => t.Field == name); if (index == null) { throw new Exception($"行字段中未找到{name}"); } return(index.GetColumnChar() + "{i}"); }); }); }