自己写了一个Dll文件
访问方法
using Db.RWM.Data;
DbRWMData myData = new DbRWMData();
DataSet mySet = my_web_userform_news.GetFieldList("*,(select A_Name from Guest_Address where a_id = O_Memo) as shouname,(select G_NAME from Guest_Info where g_id = o_GuestId) as username",sSql.ToString() + "order by O_CreateTime desc");
myData.WebExportDataSetToExcel(mySet,1);
直接导出DataSet ,如果查询的DataSet中没有你需要的列,请使用DataSet中的DataTable 进行添加自己的列,即可
前端调用:
就是直接调用接口2次即可自动下载文件
$.post( '<OutPut>DbveloperHelper.GetActionPath()</OutPut>list.aspx?action=list&isdaochu=1',function(callback){
location.href = '<OutPut>DbveloperHelper.GetActionPath()</OutPut>list.aspx?action=list&isdaochu=1';
});
结果如图: