2013-07-08 29 views
0
工作

我使用以下代碼以輸出HTML字符串與擴展名爲.docx [不.DOC]輸出字文檔作爲DOCX擴展僅在Firefox

private void ExportBodyAsDoc(string strBody) { 
    HttpContext.Current.Response.Clear(); 
    HttpContext.Current.Response.ContentType = "Application/msword"; 
    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=myfile.docx"); 
    var repo = new System.IO.MemoryStream(); 
    var stringBytes = System.Text.Encoding.UTF8.GetBytes(strBody); 
    repo.Write(stringBytes, 0, strBody.Length); 
    HttpContext.Current.Response.BinaryWrite(repo.ToArray()); 
    HttpContext.Current.Response.Flush(); 
    HttpContext.Current.Response.Close(); 
    HttpContext.Current.Response.End(); 
} 

它僅與Firefox工作,而在其它字文檔它正在破壞文件。

回答