回覆列表
  • 1 # 小百科嚦

    //sbHtml div 內容

    //fileName 匯出來後文件名

    public static void Export(StringBuilder sbHtml, string fileName)

    {

    try

    {

    if (sbHtml.Length > 0)

    {

    HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;

    HttpContext.Current.Response.Charset = "Utf-8";

    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName + ".docx", System.Text.Encoding.UTF8));

    HttpContext.Current.Response.Write(sbHtml.ToString());

    HttpContext.Current.Response.End();

    }

    }

    catch (Exception ex)

    {

    Logger.WriteLog("-----------匯出資料異常-----------\r\n" + ex.ToString() + "\r\n");

    }

  • 中秋節和大豐收的關聯?
  • 《神奇寶貝》中御三家精靈是什麼意思?