Solved

Creating Merge Documents with data via OpenXml

Posted on 2014-12-08
3
1,106 Views
Last Modified: 2014-12-29
Hi,
How do i create "mail merge", via openxml in my c# (mvc) code from template?

i have template document .docx extension, in the document there are properties.
I succeed to fill just one document, but i want to create documents in one file, with data from query or somewhere else.
for example, i have view that return 10 people data (name, address)
i have a document with text, and dynamic name and address,
my result should be 10 documents, one for each person, and all in one file, so i can print it or whatever i want.

Please I've tried everything :(
best regards,
Arie
0
Comment
Question by:aweigh
  • 2
3 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40500198
Create a NEW document for your merge and then use the "Open XML SDK" to Merge the template document into the New document.

Example on TechNet
0
 

Author Comment

by:aweigh
ID: 40500239
Hi
That's doesn't what i meant to,
I have template document with "plain text" objects, I want to replace the "plain text" with data from SQL, LinQ, List view etc. and create on run time many documents, even over 100 pages, and all should be with good perfomance , like in  memory stream.
exactly, like it's done in word template file (".dotx") with link data.

Thanks,
Arie
0
 
LVL 37

Accepted Solution

by:
Neil Russell earned 500 total points
ID: 40500271
Your starting point is going to be the OPEN XML SDK.
By "Plain Text Objects" do you mean merge fields? If not then why not? thats what mailmerge is all about, replacing fields with data.

Another great article with a working example can be found HERE

Don't try to reinvent the wheel when there are working toolkits already written that do the job.  

If you still have questions, ask away.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MailAddress in vb 4 29
Adding items to a C# list incrementally 5 28
ASP.NET MVC - Views 3 15
asp.net mvc 2 19
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question