Reputation: 32490
I am looking to do a mail merge in Word using their interop libraries. However having issues getting word installed on my developer machine due to IT at work.
Is it possible to programmatically interact with OpenOffice as an alternative? Ideally in C#
Upvotes: 1
Views: 2866
Reputation: 3545
There are a handful of third-party C# libraries that can do this, such as OfficeWriter (who I work for) and others.
Using the library and your Word document you simply call a method, passing in the data to be mail merged. The API is usually pretty strait forward:
using (WordTemplate wordTemplate = new WordTemplate())
{
wordTemplate.Open("YourFilePath.docx");
// yourData is a a DataTable in this case,
// but SetDataSource has many overloads
wordTemplate.SetDataSource(yourData);
wordTemplate.Process();
wordTemplate.Save("OutputFilePath.docx");
}
Upvotes: 2
Reputation: 3784
Microsoft provides a development platform for handling Word (.docx), Excel (.xlsx) and PowerPoint (.pptx) files without installing the softwares. The feature is avaliable like a SDK.
Look this: http://msdn.microsoft.com/en-us/office/bb265236.aspx
If you wanna more help, please try something and post.
Upvotes: 0