简体   繁体   English

如何使用打开的 xml sdk 2.0 在 Word 文档、C++\CLI 中读取书签值

[英]How to read bookmarks value in word document, C++\CLI using open xml sdk 2.0

I've created a word document using openXML SDK in C++\CLI in which I've entered Bookmarks,我在 C++\CLI 中使用 openXML SDK 创建了一个 word 文档,我在其中输入了书签,

I need to open that word document and search for the bookmarks present in it and replace it with some text value.我需要打开该 word 文档并搜索其中存在的书签并将其替换为一些文本值。

Please suggest the above with sample code or any links which I can refer.请使用示例代码或我可以参考的任何链接提出上述建议。

Thanks in advance提前致谢

I suggest a lot more specific.我建议更具体。 A bookmark can have paragraphs, images, tables, textboxes, etc. all in it.书签可以包含段落、图像、表格、文本框等。 It can also start in the middle of a table and end outside the table.它也可以从桌子中间开始,在桌子外面结束。 So replacing what's inside it can be very problematic.所以更换里面的东西可能会很成问题。

So I'm going to take a guess as to what you want and from that might have an answer for you.因此,我将猜测您想要什么,从中可能会为您提供答案。 I am guessing you want something where you place tags in the document and then your program can replace those tags with data.我猜你想要在文档中放置标签的地方,然后你的程序可以用数据替换这些标签。 Instead of bookmarks use fields.而不是书签使用字段。 There are a number of mailmerge fields that work great for this.有许多邮件合并字段对此非常有用。

If this will work for you, then for the actual code, Descendents is the main thing you need.如果这对您有用,那么对于实际代码,后代是您需要的主要内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM