基本的可以看这里:https://blog.csdn.net/luthreestone/article/details/78230777
和这里:https://docs.microsoft.com/zh-cn/dotnet/api/microsoft.office.interop.word?view=word-pia
1、首先是文件缓存路径:object path = HttpContext.Current.Server.MapPath("Export/");这次是object类型。
2、初始设置:
//应用程序
Application wordApp = new Application();
//文档
Document wordDoc;
wordApp.Visible = false;
object Nothing = Missing.Value;
wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//设置纸张样式为A4
wordDoc.PageSetup.PaperSize = WdPaperSize.wdPaperA4;