Hello,
I have some code to import a Word-document with MergeFields, than I MailMerge it with some data end export it to a new document.
This works fine, but I also want to fill a table in the document. How can this be done?
I was trying something like this, but this doesn't work ...
Thanks for any help you guys can give!
using System.Collections.Generic;
using System.IO;
using Telerik.Windows.Documents.Flow.Model;
using Telerik.Windows.Documents.Flow.FormatProviders.Docx;
public class ProccessDocument
{
public ProccessDocument()
{
RadFlowDocument importDocument = new RadFlowDocument();
DocxFormatProvider providerIn = new DocxFormatProvider();
using (Stream input = File.OpenRead("import.docx"))
{
importDocument = providerIn.Import(input);
}
RadFlowDocument exportDocument = importDocument.MailMerge(GetData());
DocxFormatProvider providerUit = new DocxFormatProvider();
using (Stream output = File.OpenWrite("export.docx"))
{
providerUit.Export(exportDocument, output);
}
}
private List<Schedule> GetData()
{
return new List<Schedule>()
{
new Schedule()
{
Name = "John",
Items = new List<Item>()
{
new Item() { Date = "11/5/2016", Subject = "Soccer training" },
}
},
new Schedule()
{
Name = "Debby",
Items = new List<Item>()
{
new Item() { Date = "10/5/2016", Subject = "Swimming" },
new Item() { Date = "12/5/2016", Subject = "Dancing" },
new Item() { Date = "15/5/2016", Subject = "Music" },
}
},
};
}
}
public class Schedule
{
public string Name { get; set; }
public List<Item> Items { get; set; }
}
public class Item
{
public string Date { get; set; }
public string Subject { get; set; }
}