TXTextControl.TextControl 类继承于 System.Windows.Forms.Control,在使用时必须依赖于Form。但是有很多情况我们不需要界面,例如在后台进行邮件合并并且导出到word,直接呈现word文档给用户。
TXTextControl提供了无界面类TXTextControl.ServerTextControl继承于System.ComponentModel.Component。ServerTextControl 可以在没有界面情况下在后台运行。如果你需要在文档展示给用户之前针对文档进行处理。你可以使用 TXTextControl.ServerTextControl 处理文档。
ServerTextControl 有以下几种优势:
- 更高效
- 支持多线程
- 无界面
- 占用内存少
使用 ServerTextControl,需要添加 TXTextControl.Server.dll 和 licenses.licx 文件,license文件内容如下:
TXTextControl.ServerTextControl, TXTextControl.Server, Culture=neutral, PublicKeyToken=6b83fe9a75cfb638
下面代码用户创建 ServerTextControl。
using (TXTextControl.ServerTextControl serverTextControl1
= new TXTextControl.ServerTextControl())
{serverTextControl1.Create();...}
MailMerge 同样可以和 ServerTextControl 配合使用,进行数据合并。
Demo 下载:VS2013 + C# + TX Text Control