我正在尝试使用 Spire.Doc 生成一个 Word 文档并下载它。我可以下载文件,但它是空的。有谁知道为什么会这样并且可以帮助我?这是我的代码:
Document doc = new Document();
Paragraph paragraph = doc.AddSection().AddParagraph();
paragraph.AppendText("Hello World!");
doc.SaveToFile("Example.doc", FileFormat.Doc);
//Saves the Word document to MemoryStream
MemoryStream stream = new MemoryStream();
stream.Position = 0;
//Download Word document in the browser
return File(stream, "application/msword", "Example.doc");