In fact, it is easy to use the ASP.NET output of Word, Excel, TXT, HTM and other types of documents such as the specified content. It is mainly divided into three steps. First, define document type, character encoding response.clear (); response.buffer = true; response.charset = "UTF-8"; // This trip is important, Attachment parameter represents as an attachment download, you can change to ONLINE Online Open //FileName =FileFlow.xls Specifies the name of the output file, pay attention to its extension and specified file type, which can be: .doc .xls .txt .htm response.appendheader ("Content-Disposition", "Attachment; FileName = FileFlow.xls "); response.contentencoding = system.text.Encoding.Getencoding (" UTF-8 "); //Response.contentType Specify file type can be Application / MS-Excel Application / MS-Word Application / MS-TXT Application / MS-HTML or other browser can directly support document response.contenttype = "Application / MS-Excel"; this.enableviewState = false; Second, define a input stream system.io.stringWriter ostringWriter = new system.io.stringWriter (); System.Web.ui.htmlTextWriter OhtmlTextWriter = new system.web.ui.htmlTextWriter; 3 You can also bind DataGrid, or other control response.write (ostringwriter.tostring ()); response.end (); response.end (); Summary: This routine is tested under the Microsoft Visual Studio .Net 2003 platform, for C # and VB, change the THIS keyword to ME when using VB.