0
我試圖做到這一點對ASP.NET MVC 4:流Word文檔的OpenXML的SDK得到腐敗的文件
MemoryStream mem = new MemoryStream();
using (WordprocessingDocument wordDoc =
WordprocessingDocument.Create(mem, DocumentFormat.OpenXml.WordprocessingDocumentType.Document, true))
{
// instantiate the members of the hierarchy
Document doc = new Document();
Body body = new Body();
Paragraph para = new Paragraph();
Run run = new Run();
Text text = new Text() { Text = "The OpenXML SDK rocks!" };
// put the hierarchy together
run.Append(text);
para.Append(run);
body.Append(para);
doc.Append(body);
//wordDoc.Close();
///wordDoc.Save();
}
return File(mem.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ABC.docx");
然而ABC.docx打開爲損壞並且止跌」即使修復後也不會打開。
任何想法?
鏈接Qs的:
Streaming In Memory Word Document using OpenXML SDK w/ASP.NET results in "corrupt" document