如何使用 Office.Interop 确定书签所属的表格单元格
我正在用 C# 创建一个应用程序。该应用程序需要根据模板创建 MS Word 文档。该模板包含一个表格和存储在表格单元格之一中的书签。我需要引用该单元格,即我需要确定它的行和列。
I am creating an application in C#. That application needs to create a MS Word document out of the template. That template contains a table and a bookmark stored in one of the table's cells. I need to reference that cell, i.e. I need to determine it's row and column.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,事实证明这很麻烦。不过,我想出了一个小技巧:
书签与表格单元格没有任何关系。无法从书签确定单元格。然而,可能的是在添加书签的位置设置值,然后迭代表单元格以查找该值。找到该值后,我们可以引用该单元格并在必要时删除该值。因此,(temp) 值充当书签和单元格之间的中介。整洁的!
Well, this turned out to be quite a nuisance. However, I came up with a little trick:
Bookmarks are not related to table cells in any way. There is no way to determine the cell from bookmark. What is possible, however, is to set the value at the bookmarked position and then to iterate through the table cells looking for that value. Once the value is found, we can reference the cell and delete that value if necessary. So, the (temp) value serves as a mediator between the bookmark and the cell. Neat!
我的第一篇文章(请温柔)。无论如何,这个怎么样:
My First post (please be gentle). Anyway, how about this: