Export excel using page table

From , 2 Years ago, written in C#, viewed 229 times.
URL https://pastebin.vip/view/40173ea4
  1.  
  2. public static void ExportExcel(string FileName, StringBuilder table)
  3.         {
  4.             HttpContext.Current.Response.ClearContent();
  5.             HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流的字符集
  6.             HttpContext.Current.Response.Charset = "gb2312";
  7.             HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName));
  8.  
  9.             HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
  10.             StringWriter sw = new StringWriter(table);
  11.             //HtmlTextWriter htw = new HtmlTextWriter(sw);
  12.  
  13.             //Page page = new Page();
  14.             //page.EnableEventValidation = false;
  15.             //page.DesignerInitialize();
  16.             //page.RenderControl(htw);
  17.             HttpContext.Current.Response.Write("<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=gb2312\"/>" + sw.ToString());
  18.             HttpContext.Current.Response.Flush();
  19.             HttpContext.Current.Response.End();
  20.         }

Reply to "Export excel using page table"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website