RouteConfig里面加一个
routes.MapRoute(
name: "Download",
url: ""
);
然后用ajax 访问Execl 运行的
public string OutAllCompany()
{
Dictionary<string, string> execl = new Dictionary<string, string>()
{
{"CoId","公司ID" },
{"CoName","公司名称" },
{"CoCompanytype","公司性质" },
{"CoRemark","备注" },
{"CoCreateddate","创建时间" },
{"CoCreateUsId","创建人" },
{"CoUptUsid","修改人" },
{"CoUptDate","修改时间" },
{"CoIsdeleted","是否删除" },
{"CoDelUsId","删除人" },
{"CoDelDate","删除时间" },
{"CoAddress","公司地址" }
};
string CompanyInfo = Client.GetApi("http://localhost:54098/api/", ResuFull.get, "Company/GetCompany");
List<Company> list = JsonConvert.DeserializeObject<List<Company>>(CompanyInfo);
string url = ExcelHelper.EntityListToExcel2003(execl,list, "公司信息表");
return Url.RouteUrl("Download")+url;//************************************
}
function DaoChu() {
$.ajax({
url: "/Company/OutAllCompany",
success: function (data) {
location.href = data;
}
})
}