2
我有基本的代碼,在控制檯中創建文件(見下文)..但我正在寫一個MVC應用程序,所以我需要返回該XML文件作爲ActionResult ....我一直在尋找網絡2小時尋找一個簡單的例子,沒有運氣..如何返回OPENXML Word文檔的MVC ActionResult?
什麼我添加到這使它成爲一個ActionResult?
string filePath = @"C:\temp\OpenXMLTest.docx";
using (WordprocessingDocument doc = WordprocessingDocument.Create(filePath, WordprocessingDocumentType.Document))
{
//// Creates the MainDocumentPart and add it to the document (doc)
MainDocumentPart mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document(
new Body(
new Paragraph(
new Run(
new Text("Hello World!!!!!")))));
}