利用ASP.NET输出指定内容的WORD、EXCEL、TXT、HTM
生活随笔
收集整理的這篇文章主要介紹了
利用ASP.NET输出指定内容的WORD、EXCEL、TXT、HTM
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
利用ASP.NET輸出指定內容的WORD、EXCEL、TXT、HTM等類型的文檔很容易的。主要分為三步來完成。
一、定義文檔類型、字符編碼
Response.Clear();
Response.Buffer= true;
Response.Charset="utf-8";
//下面這行很重要, attachment 參數表示作為附件下載,您可以改成 online在線打開
//filename=FileFlow.xls 指定輸出文件的名稱,注意其擴展名和指定文件類型相符,可以為:.doc .xls .txt .htm
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
//Response.ContentType指定文件類型 可以為application/m*-**cel application/ms-word application/ms-txt application/ms-html 或其他瀏覽器可直接支持文檔
Response.ContentType = "application/m*-**cel";
this.EnableViewState = false;
利用ASP.NET輸出指定內容的WORD、EXCEL、TXT、HTM等類型的文檔很容易的。主要分為三步來完成。
一、定義文檔類型、字符編碼
Response.Clear();
Response.Buffer= true;
Response.Charset="utf-8";
//下面這行很重要, attachment 參數表示作為附件下載,您可以改成 online在線打開
//filename=FileFlow.xls 指定輸出文件的名稱,注意其擴展名和指定文件類型相符,可以為:.doc .xls .txt .htm
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
//Response.ContentType指定文件類型 可以為application/m*-**cel application/ms-word application/ms-txt application/ms-html 或其他瀏覽器可直接支持文檔
Response.ContentType = "application/m*-**cel";
this.EnableViewState = false;
利用ASP.NET輸出指定內容的WORD、EXCEL、TXT、HTM等類型的文檔很容易的。主要分為三步來完成。
一、定義文檔類型、字符編碼
Response.Clear();
Response.Buffer= true;
Response.Charset="utf-8";
//下面這行很重要, attachment 參數表示作為附件下載,您可以改成 online在線打開
//filename=FileFlow.xls 指定輸出文件的名稱,注意其擴展名和指定文件類型相符,可以為:.doc .xls .txt .htm
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
//Response.ContentType指定文件類型 可以為application/m*-**cel application/ms-word application/ms-txt application/ms-html 或其他瀏覽器可直接支持文檔
Response.ContentType = "application/m*-**cel";
this.EnableViewState = false; ?
一、定義文檔類型、字符編碼
Response.Clear();
Response.Buffer= true;
Response.Charset="utf-8";
//下面這行很重要, attachment 參數表示作為附件下載,您可以改成 online在線打開
//filename=FileFlow.xls 指定輸出文件的名稱,注意其擴展名和指定文件類型相符,可以為:.doc .xls .txt .htm
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
//Response.ContentType指定文件類型 可以為application/m*-**cel application/ms-word application/ms-txt application/ms-html 或其他瀏覽器可直接支持文檔
Response.ContentType = "application/m*-**cel";
this.EnableViewState = false;
利用ASP.NET輸出指定內容的WORD、EXCEL、TXT、HTM等類型的文檔很容易的。主要分為三步來完成。
一、定義文檔類型、字符編碼
Response.Clear();
Response.Buffer= true;
Response.Charset="utf-8";
//下面這行很重要, attachment 參數表示作為附件下載,您可以改成 online在線打開
//filename=FileFlow.xls 指定輸出文件的名稱,注意其擴展名和指定文件類型相符,可以為:.doc .xls .txt .htm
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
//Response.ContentType指定文件類型 可以為application/m*-**cel application/ms-word application/ms-txt application/ms-html 或其他瀏覽器可直接支持文檔
Response.ContentType = "application/m*-**cel";
this.EnableViewState = false;
利用ASP.NET輸出指定內容的WORD、EXCEL、TXT、HTM等類型的文檔很容易的。主要分為三步來完成。
一、定義文檔類型、字符編碼
Response.Clear();
Response.Buffer= true;
Response.Charset="utf-8";
//下面這行很重要, attachment 參數表示作為附件下載,您可以改成 online在線打開
//filename=FileFlow.xls 指定輸出文件的名稱,注意其擴展名和指定文件類型相符,可以為:.doc .xls .txt .htm
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
//Response.ContentType指定文件類型 可以為application/m*-**cel application/ms-word application/ms-txt application/ms-html 或其他瀏覽器可直接支持文檔
Response.ContentType = "application/m*-**cel";
this.EnableViewState = false; ?
轉載于:https://www.cnblogs.com/hainange/archive/2007/09/22/6153332.html
總結
以上是生活随笔為你收集整理的利用ASP.NET输出指定内容的WORD、EXCEL、TXT、HTM的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 创建对象的序列化文件 - SoapFor
- 下一篇: [转]C#导出到EXCEL