.net 导出excel 并保存至服务器指定路径,求样例,急!正确即采纳 100
我现在有导出成excel文件但是是打开还没报存求报存这份excel到指定路径的求后台代码...
我现在有导出成excel文件 但是是打开 还没报存 求报存这份excel 到指定路径的 求后台代码
展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏100(财富值+成长值)
展开全部
//导出Excel
Workbook workBook = new Workbook();
....
//保存
string path = Request.PhysicalApplicationPath + "Upload\\Excel\\" + DateTime.Now.ToString("yyMMddHHmmss") + ".xls";
workBook.Save(path);//保存
//输出Excel
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
Response.ContentType = "application/ms-excel";
Response.WriteFile(file.FullName);
Response.End();
Workbook workBook = new Workbook();
....
//保存
string path = Request.PhysicalApplicationPath + "Upload\\Excel\\" + DateTime.Now.ToString("yyMMddHHmmss") + ".xls";
workBook.Save(path);//保存
//输出Excel
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
Response.ContentType = "application/ms-excel";
Response.WriteFile(file.FullName);
Response.End();
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询