好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > asp.net導出Excel亂碼的原因及解決方法

asp.net導出Excel亂碼的原因及解決方法

熱門標簽:怎樣給陜西地圖標注顏色 福州人工智能電銷機器人加盟 電銷機器人 數據 云狐人工智能電話機器人 宿遷智能外呼系統排名 400電話辦理信任翰諾科技 廣州銷售外呼系統定制 ai電銷機器人對貸款有幫助嗎 地圖標注多少錢一張
復制代碼 代碼如下:

protected void Excel_Click(object sender, EventArgs e)
{
Response.Charset = "UTF-8";
Response.ClearContent();
Response.Clear();
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.HeaderEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("content-disposition", "attachment; filename=MyExpress.xls");
Response.ContentType = "application/excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
// turn off paging
GridView1.AllowPaging = false;
dataBind();
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
// turn the paging on again
GridView1.AllowPaging = true;
dataBind();
}

關鍵:
復制代碼 代碼如下:

Response.Charset = "UTF-8";//添加編碼格式
Response.ClearContent();
Response.Clear();
Response.ContentEncoding = System.Text.Encoding.UTF8;//表格內容添加編碼格式
Response.HeaderEncoding = System.Text.Encoding.UTF8;//表頭添加編碼格式

上邊如果解決不了還可以用
復制代碼 代碼如下:

Response.ClearContent();
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=sumlate.xls");
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
if (GridView2.Rows.Count > 0)
{
GridView2.RenderControl(htw);
}
else
{
GridView1.RenderControl(htw);
}
Response.Write(sw.ToString());
Response.End();

關鍵:
復制代碼 代碼如下:

Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");

注意觀察,主要原因其實就是編碼格式問題。

現在就能防止導出時候亂碼問題了
您可能感興趣的文章:
  • 直接在線預覽Word、Excel、TXT文件之ASP.NET
  • ASP.NET使用GridView導出Excel實現方法
  • asp.net導出excel數據的常見方法匯總
  • Asp.net導出Excel/Csv文本格式數據的方法
  • Asp.Net使用Npoi導入導出Excel的方法
  • asp.net使用npoi讀取excel模板并導出下載詳解
  • ASP.NET導出數據到Excel的實現方法
  • .Net中導出數據到Excel(asp.net和winform程序中)
  • asp.net生成Excel并導出下載五種實現方法
  • ASP.NET導出Excel打開時提示:與文件擴展名指定文件不一致解決方法
  • asp.net中如何批量導出access某表內容到word文檔
  • asp.net 按指定模板導出word,pdf實例代碼
  • asp.net+Ligerui實現grid導出Excel和Word的方法

標簽:綿陽 新疆 黃南 大興安嶺 宜春 焦作 曲靖 延安

巨人網絡通訊聲明:本文標題《asp.net導出Excel亂碼的原因及解決方法》,本文關鍵詞  asp.net,導出,Excel,亂碼,的,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《asp.net導出Excel亂碼的原因及解決方法》相關的同類信息!
  • 本頁收集關于asp.net導出Excel亂碼的原因及解決方法的相關信息資訊供網民參考!
  • 推薦文章