Solved

Creating Merge Documents with data via OpenXml

Posted on 2014-12-08
3
1,069 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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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