Aspose.Words 直接写response导出docx文档显示文件已损坏需要修复的解决办法

使用Aspose.Words的Document.Save(HttpResponse response, string fileName, ContentDisposition contentDisposition, Aspose.Words.Saving.SaveOption saveOption)方法,将Document直接写入response时,需要加Response.End();

Document doc = new Document(postedFile.InputStream);
doc.Save(Response, dstFileName, ContentDisposition.Inline, SaveOptions.CreateSaveOptions(dstFormat));
// Required. Otherwise DOCX cannot be opened on the client (probably not all data sent
 // or some extra data sent in the response).
Response.End();

请注意注释部分!!

 

posted @ 2015-09-16 23:37  drsniper  阅读(1811)  评论(0编辑  收藏  举报