private TXTextControl.DocumentServer.MailMerge mailMerge1;
private TXTextControl.ServerTextControl serverTextControl1;
private System.ComponentModel.IContainer components;
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.mailMerge1 = new TXTextControl.DocumentServer.MailMerge(this.components);
this.serverTextControl1 = new TXTextControl.ServerTextControl();
this.mailMerge1.ReportDataSourceConfig = "";
this.mailMerge1.TextComponent = this.serverTextControl1;
this.serverTextControl1.SpellChecker = null;
}
protected void Page_Load(object sender, EventArgs e)
{
InitializeComponent();
TextControl1.LoadText(Server.MapPath("/documents/hlxx.docx"),
TXTextControl.Web.StreamType.WordprocessingML);
byte[] data;
TextControl1.SaveText(out data,
TXTextControl.Web.BinaryStreamType.InternalUnicodeFormat);
// load the template into the MailMerge reporting engine
mailMerge1.LoadTemplateFromMemory(data,
TXTextControl.DocumentServer.FileFormat.InternalUnicodeFormat);
DataTable dt = new DataTable();
dt.Columns.Add("s_hospital_no");
dt.Rows.Add("20156666");
// merge the template
mailMerge1.Merge(dt);
// save the resulting document to a byte array
mailMerge1.SaveDocumentToMemory(out data,
TXTextControl.BinaryStreamType.InternalUnicodeFormat, null);
// load the document back into the Web editor
TextControl1.LoadText(data,
TXTextControl.Web.BinaryStreamType.InternalUnicodeFormat);
}
页面加载的时候执行这个会报“Server not ready”,我想实现的功能:页面加载的时候将邮件合并后的数据展示出来 |