Solved

Creating Merge Documents with data via OpenXml

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now