ASP.NET operating Word Excel et al.

zhaozj2021-02-16  57

Byte [] fileData = (byte []) ds.tables [0] .rows [0] ["fileData"]; then display response.contenttype = "Application / Msword" with the following statement; response.addheader ("Content- Disposition, "Inline; filename =" server.urlencode (filename) .Replace (" ", "")); response.binaryWrite (FileData); response.end ();

IF (DR ["DOCTYPE"]. TOSTRING () == "Application / Msword") {response.contenttype = "Application / msword";} else {response.contenttype = "Application / VND.MS-Excel";} Response .Addic-dispositioner ("DOCTITLE", DR ["DOCTITLE"]. Tostring ()); response.flush (); response.binaryWrite ((byte []) DR ["DOCTEXT"]); response.end ();

public void ToWord (System.Web.UI.Control ctl) {HttpContext.Current.Response.AppendHeader ( "Content-Disposition", "attachment; filename = 1.doc"); HttpContext.Current.Response.Charset = "UTF- 8 "; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; HttpContext.Current.Response.ContentType =" application / msword "; // image / JPEG; text / HTML; image / GIF; vnd.ms -excel / msword ctl.Page.EnableViewState = false; System.IO.StringWriter tw = new System.IO.StringWriter (); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw); ctl .RenderControl (HW); httpContext.current.response.write (Tw.toString ()); httpContext.current.response.end ();}

Response.Clear (); response.contenttype = "Application / Msword"; Response.addheader ("Content-Disposition", "Attachment; FileName = xxx.doc");

Response.flush (); response.write (TEST); response.end ();

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

New Post(0)