Solved

Creating Merge Documents with data via OpenXml

Posted on 2014-12-08
3
939 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wpf develop 5 30
ASP.net VB.net Email  a webpage 3 24
Check if number is currency 15 29
Loop through Multiple Processes Async 2 15
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

743 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

10 Experts available now in Live!

Get 1:1 Help Now