编辑Word文档

发布于 2024-07-17 07:08:42 字数 129 浏览 1 评论 0原文

是否可以在 SharePoint 上托管的 Word 文档中编辑和插入条目?

我需要根据最后一次对文档进行更改的人填写审阅者表格。

我知道我会使用事件接收器来执行此操作,但如何与 Word 文档交互交互?

Is it possible to edit and insert entries in a word document that is hosted on SharePoint?

I need to fill in a reviewer's table based on who made the last change to the document.

I know I would use an event receiver to do this, but how do I interact with the word document interactively?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

临走之时 2024-07-24 07:08:42

您希望使用 SPListItem 的 CreatedBy 或 ModifiedBy 值以及 OpenXml API 来执行此操作,这样您就不必使用 WSS/MOSS 服务器上的 Word 对象模型。

要获取用户信息,您需要这样做。

//get the SPWeb reference for web
SPFile updatedFile= web.GetFile(fileUrl);
SPUser author = updatedFile.Author; //or updatedFile.ModifiedBy for modifier

有了作者后,要更新 Word 文档,可以参考此 SharePoint 和 OpenXml wiki 页面以获取一些帮助。 这是基于 Eric White 的博客(和其他人)使用 Open Xml。 我强烈建议您阅读他的博客并查看 PowerTools for OpenXml Codeplex 项目,以获取一些肯定会的代码乐于助人。

另请参阅 OpenXmlDeveloper打开 XML 开发人员门户 了解更多信息

希望这会有所帮助。

You want to use the an SPListItem's CreatedBy or ModifiedBy values and the OpenXml API to do this so you do not have to use the Word Object Model on the WSS/MOSS Server.

To obtain the user information, you'll want to to something like this.

//get the SPWeb reference for web
SPFile updatedFile= web.GetFile(fileUrl);
SPUser author = updatedFile.Author; //or updatedFile.ModifiedBy for modifier

Once you have the author, to update the Word document, you can refer to this SharePoint and OpenXml wiki page for some assistance. This is based on Eric White's blog (and others) with Open Xml. I highly suggest you read his blog and look at the PowerTools for OpenXml Codeplex project for some code that will definitely be helpful.

Also see OpenXmlDeveloper and Open XML Developer portal for more information

Hope this helps.

×纯※雪 2024-07-24 07:08:42

您可以使用 SPDocumentLibrary 类和方法GetItemsInFolder 返回 SPListItemCollection。

从那里,您可以将项目转换为 Word 对象,并通过 单词对象模型

You can use the SPDocumentLibrary class and the method GetItemsInFolder to return a SPListItemCollection.

From there you can cast an item to a Word object and manipulate it through the word object model

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文