Last active
August 29, 2015 14:25
-
-
Save bjoerntx/cf00d693f35c72e7ce23 to your computer and use it in GitHub Desktop.
Form1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string sDataSource = "data.xml"; | |
private string sTemplateFile = "template.tx"; | |
private void mergeToolStripMenuItem_Click(object sender, EventArgs e) | |
{ | |
// convert the XML file to a .NET DataSet | |
DataSet ds = new DataSet(); | |
ds.ReadXml(sDataSource, XmlReadMode.Auto); | |
// create a new DataSelector instance | |
DataSelector selector = new DataSelector(ds, | |
File.ReadAllBytes(sTemplateFile)); | |
// load the modified template | |
mailMerge1.LoadTemplateFromMemory(selector.Template, | |
TXTextControl.DocumentServer.FileFormat.InternalUnicodeFormat); | |
// merge the template with the new, sorted data source | |
mailMerge1.Merge(ds.Tables[0]); | |
// copy the merged document into a visible TextControl object | |
byte[] data = null; | |
mailMerge1.SaveDocumentToMemory(out data, | |
TXTextControl.BinaryStreamType.InternalUnicodeFormat, null); | |
textControl1.Load(data, | |
TXTextControl.BinaryStreamType.InternalUnicodeFormat); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment