Response.Clear() Response.buffer = true
Response.ContentType = "application/vnd.ms-excel;utf-8"
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312")
'Response.Charset = "utf-8"
Response.ContentType = "application/vnd.ms-excel;utf-8"
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312")
'Response.Charset = "utf-8"
If Instr(1, Request.ServerVariables("HTTP_USER_AGENT"), "MSIE 4.01") > 0 then
Response.AddHeader("Content-Disposition","inline;filename="+DateTime.Now.Tostring("yyyy-MM-dd")+".xls")
Else
Response.AddHeader("Content-Disposition","attachment;filename="+DateTime.Now.Tostring("yyyy-MM-dd")+".xls")
End If Response.AddHeader("Content-Disposition","inline;filename="+DateTime.Now.Tostring("yyyy-MM-dd")+".xls")
Else
Response.AddHeader("Content-Disposition","attachment;filename="+DateTime.Now.Tostring("yyyy-MM-dd")+".xls")
本文介绍了一种使用ASP.NET进行Excel文件导出的方法。通过设置Response对象的属性,可以实现浏览器直接下载指定日期命名的Excel文件。此方法兼容不同版本的Internet Explorer浏览器。
632

被折叠的 条评论
为什么被折叠?



