Note that there are some explanatory texts on larger screens.

plurals
  1. POOffice Open XML SDK word replacing
    text
    copied!<p>For creating word documents based on data from an SQL database, I'm using Office Open XML SDK to avoid using interop. This speeds up the process and it eliminates the requirement for a Microsoft office suite installed on the client system.</p> <p>While this works very well, there is a problem I'm having when replacing certain text in the document. To keep customization of the final document an option, I've created a document with some tags in it as a template. This template contains tags such as [TagHere]. Since the tag names should be easy readable, they could be used throughout the document, which is why I've surrounded the tag with braces [].</p> <p>This works quite well, but sometimes, an issue comes up. When you're typing in a docx document, the text can be split up into multiple tags, even in the same word. A tag like [TagHere] can be split up into </p> <blockquote> <p><code>&lt;tag&gt;[&lt;/tag&gt;&lt;tag&gt;TagHere&lt;/tag&gt;&lt;tag&gt;]&lt;/tag&gt;</code></p> </blockquote> <p>When this happens, the replacement won't work.</p> <p>Now the docx format has some alternative options to do this kind of operations, such as Content Controls, but these make the process of creating the template more complex. Furtermore, it is not uncommon in these documents to get one row of a table with tags and copy it multiple of times, which would probably break the content tag principle. Hence I've chosen to not use this option.</p> <p>It would be great if someone has a solution to this problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload