DataGrid generates a Word document

xiaoxiao2021-03-06  61

The following code generates the DataGrid to the Word document and generates httpContext.current.response.Appendext.current.response.appendheader ("Content-Disposition", "Content-Disposition", "); resplication.contentType =" Application / VND. ms-word "; // the specified file type generated HttpContext.Current.Response.Charset =" "; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; System.IO.StringWriter tw = new System.IO .StringWriter (); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw) DataGrid1.RenderControl (hw); // datagrid turn into stringHttpContext.Current.Response.Write (hw.tosting () HttpContext.current.Response.end ();

// Show response.clearContent (); response.clearheaders (); response.contenttype = "Application / msword"; respternse.writefile ("Roadrepair.doc"); response.flush (); response.close ();

转载请注明原文地址:https://www.9cbs.com/read-113815.html

New Post(0)