您的位置:首页 > 移动开发 > Objective-C

导出Excel的简单方法,并可以解决乱码问题

2006-07-18 15:56 736 查看
private void HB_ToExecl_Click(object sender, System.EventArgs e)
  {
   HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=Excel.xls");
   HttpContext.Current.Response.Charset =""; 
   HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.UTF8;
   HttpContext.Current.Response.ContentType ="application/ms-excel";
   ctl.Page.EnableViewState =false;                       
   System.IO.StringWriter  tw = new System.IO.StringWriter() ;
   System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
   ctl.RenderControl(hw);
   HttpContext.Current.Response.Write("<head><meta http-equiv=/"Content-Type/" content=/"text/html; charset=utf-8/"></head><body>"+tw.ToString()+"</body>");
   HttpContext.Current.Response.End();
  } 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  excel object