private static string GetResult(NameValueCollection queryString, int page, MDataTable result, string colName) { if (page != 0 || queryString["page"].IsNullOrEmpty()) { return(result.ToJson().Replace(" 00:00:00", "")); } //更改列名为中文名 var colNames = colName.Split('~'); var shouldRemoveColNames = new List <string>(); foreach (var column in result.Columns) { var dtColName = column.ColumnName; var index = colNames.IndexOf(dtColName); if (index >= 0) { column.ColumnName = colNames[index + 1]; continue; } shouldRemoveColNames.Add(dtColName); } //移除无需导出的列 foreach (var removeColName in shouldRemoveColNames) { result.Columns.Remove(removeColName); } var tablename = result.TableName; var filename = SAction.GetOneValue <string>("SysTableFilename", "tablename".ToWhere(tablename), "Filename"); filename = filename.IsNullOrEmpty() ? tablename : filename; var workbook = result.ToWorkbook(); workbook.SetSheetName(0, filename); ExportExcel.WriteExcel(workbook, filename); return(null); }