下载EXCEL (等待完整)
public static void excelbase() { string filename = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Second.ToString() + System.DateTime.Now.Millisecond.ToString() + ".xls"; try { string style = @"<style> td { mso-number-format:\@; } </style>"; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename + ""); HttpContext.Current.Response.ContentType = "application/ms-excel"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF7; // Response.Charset = "utf-8"; // Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); stringWrite.WriteLine(style); // gvAsset.RenderControl(htmlWrite); HttpContext.Current.Response.Write(stringWrite.ToString()); HttpContext.Current.Response.End(); } catch (Exception ex) { // throw new Exception(ex.Message.ToString()); } }