/// <summary> /// 格式化Excel列头和Config_KeyValue数据。 /// </summary> protected bool FormatExcel(MDataTable dt, MDataRow excelInfo) { //翻译列头。 Dictionary <string, string> formatterDic = ExcelConfig.FormatterTitle(dt, excelInfo, ObjName);// //翻译字典值,处理默认值。 bool result = KeyValueConfig.FormatNameValue(dt, formatterDic, false); //校验基础数据类型。 result = ExcelConfig.ValidateData(dt, excelInfo) && result; if (result)//验证是否存在有错误信息 { int index = dt.Columns.GetIndex("错误信息"); if (index > -1) { foreach (var row in dt.Rows) { if (!row[index].IsNullOrEmpty) { result = false; break; } } } } dt.SetState(2, BreakOp.NullOrEmpty); return(result); }
public void Export() { MDataTable dt = Select(GridConfig.SelectType.Export); dt.TableName = ObjName; dt.DynamicData = GridConfig.GetList(ObjName, GridConfig.SelectType.All); Dictionary <string, string> formatParas = GridConfig.SetHeaderDescription(dt); //格式化列头(描述)(需要修改列头的数据格式) KeyValueConfig.FormatNameValue(dt, formatParas, true); //格式化配置项 WebHelper.SendFile(KeyValueConfig.GetTableDescription(ObjName, TableName) + "_" + DateTime.Now.ToString("yyyyMMdd") + ".xls", ExcelHelper.CreateExcel(dt)); //ExcelHelper.CreateExcel(dt) }
public virtual void Export() { MDataTable dt = Select(GridConfig.SelectType.Export); dt.TableName = ObjName; dt.DynamicData = GridConfig.GetList(ObjName, GridConfig.SelectType.Export); Dictionary <string, string> formatParas = GridConfig.GetFormatter(dt); //格式化列头(描述)(需要修改列头的数据格式) KeyValueConfig.FormatNameValue(dt, formatParas, true); //格式化配置项 string fix = ExcelHelper.BookType == ExcelHelper.WorkBookType.High ? ".xlsx" : ".xls"; WebHelper.SendFile(KeyValueConfig.GetTableDescription(ObjName, TableName) + "_" + DateTime.Now.ToString("yyyyMMdd") + fix, ExcelHelper.CreateExcel(dt));//ExcelHelper.CreateExcel(dt) }