SharpDocx icon indicating copy to clipboard operation
SharpDocx copied to clipboard

Is it possible to assemble documents?

Open remesq opened this issue 2 years ago • 2 comments

Is there a relatively easy way to combine two or more documents into a final document?

I could just create one large template and use conditionals to control the display of paragraphs/pages. However, I'm wondering if it's possible to, for example, use logic in the Program.cs or similar file to merge different templates as needed.

My scenario: I could have a full template with 10 parts. In many situations I may only need "x" of 10 of those parts (i.e., not all 10 parts). I'm wondering if I can control what parts need to be inserted into the final documents. So, I would consider having logic in the code to pick what I need from 10 separate templates and merging it into one final document.

Currently, I am using the former approach of using conditionals, but my template is a bit cumbersome.

remesq avatar Mar 18 '22 16:03 remesq

@remesq did you ever figure this out?

I'm trying to figure our a clean way to have a generic header and footer for our generated documents, meaning the header and footer would essentially be it's own report, and then other documents would have the content which needs to be run through the template engine & merged :o

jarodsmk avatar Jun 02 '22 10:06 jarodsmk

@remesq I've done this, and I made a document generation platform! You can use Open-Xml-PowerTools to combine docs QQ截图20220917223647

@jarodsmk a generic header and footer this is same above, you could use Open-Xml-PowerTools, It can handle header and footer.

autukill avatar Sep 17 '22 14:09 autukill

Combining documents is not supported by SharpDocx, I would also use Open-Xml-PowerTools for this.

egonl avatar Oct 03 '23 09:10 egonl