Duplicate a content of a word document? RRS feed

  • Question

  • Hello,

    In order to generate a serial Word document from database I would need to do search and replace followed by content duplication in a loop using OpneXML library. Let's say that the customer has two-page docx template with prepared tags that needs to be filled with data of all employes. The result should be a multipage document with repeated template.

    Something like this:

    public replace(WordprocessingDocument myDoc)
     // 1. Create a duplication block, duplicate basically the entire document 
     DuplicationBlock duplicationBlock = myDoc.Get(TheContent);
     foreach (/*Database row*/)
      // 2. Commit search and replace in myDoc
      SearchAndReplace(myDoc); // easy
      // 3. Add duplication block 

    While step 2 is quite easy I am not able to implement step 1 and 3.

    Any advice greatly appreciated!

    Friday, July 16, 2010 9:44 AM