在努力让我的 word 文档在我的本地机器上正常运行后,我了解到我的服务器没有 Microsoft Office。我正在尝试打开、修改、保存和显示文档。我发现 OPEN XML SDK 2.0 是要走的路。我今天早上刚下载了这个程序,我不知道如何将它集成到我的代码中。我该怎么做呢?
我瞎了眼,这就是我想做的。此代码适用于办公室
object pathToUse = Server.MapPath("~/Document/TemplateX.docx");
object pathToSave = Server.MapPath("~/Document/FinishedX.docx");
//open file
tempDoc = wordApp.Documents.Open(ref pathToUse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref isVisible, ref missing, ref missing,
ref missing, ref missing);
//Make edits - I had this for my word document
this.FindAndReplace(Application wordApp, "<date>", DateTime.Today.ToShortDateString());
//save
tempDoc.SaveAs(ref pathToSave, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref isVisible, ref missing, ref missing,
ref missing, ref missing);
//return file in my Controller
return File(pathToSave.ToString(), "docx");
我只是添加了代码来显示我有需要的东西,但是缺少 Microsoft 曲线球伤害了我的心理。提前致谢。帮助!