HttpResponse resp= HttpContext.Current.Response;
//设置内容编码
resp.ContentEncoding= System.Text.Encoding.GetEncoding("GB2312");
//设置标题编码
resp.HeaderEncoding= System.Text.Encoding.GetEncoding("GB2312");
resp.AppendHeader("Content-Disposition","attachment;filename=" + this.FileName + ".xls");
resp.Write("<metahttp-equiv=Content-Type content=\"text/html;charset=GB2312\">");
//设置输出文件类型为excel文件。
resp.ContentType= "application/ms-excel";
//填写输出内容
resp.Write(m_outPutJS); m_outPutJS为内容
//写缓冲区中的数据到HTTP头文件中 HttpContext.Current.ApplicationInstance.CompleteRequest();
resp.End();