问题
There are a lot of questions, answers and posts about openXml, mainly good, thorough stuff that Eric White posts here (also here and other stack-overflow questions). The thing is the examples have two characteristics that make it difficult for me to apply: First, they are extremely end-to-end in the sense thay take care of every possible scenario possilbe (Like Eric White's XML flattening solution) and thus making the code too complicated. Second, the examples are more snippets and less entire code, and me, being a beginner with openXml, cannot figure out all the "usings" and the instantiations required before the snippet.
I would appreciate your help in two specific simple scenarios:
- Replacing a bookmark with text and preserving the style. This bookmark is simple, in the middle of a line, with non-changing style.
- Replacing a bookmark with an image from a file.
I have been using Office Interop till now and it's heavy, cumbersome and requires the Word application to be open. Not nice.
来源:https://stackoverflow.com/questions/13437250/manipulating-simple-bookmarks-in-word