//[System.STAThread] //static void Main() //{ // TestWriteFile(); // TestClipboard(); //} /// <summary> /// 测试生成RTF文件 /// 执行这个函数后可以使用 MS Word 打开文件 c:\a.rtf /// </summary> internal static void TestWriteFile() { RTFWriter w = new RTFWriter("c:\\a.rtf"); TestBuildRTF(w); w.Close(); System.Windows.Forms.MessageBox.Show("好了,你可以打开文件 c:\\a.rtf 了."); }
/// <summary> /// 测试生成RTF文档并设置到系统剪切板中 /// 执行这个函数后就可以在 MS Word中使用粘贴操作来显示程序生成的文档了 /// </summary> internal static void TestClipboard() { System.IO.StringWriter myStr = new System.IO.StringWriter(); RTFWriter w = new RTFWriter(myStr); TestBuildRTF(w); w.Close(); System.Windows.Forms.DataObject data = new System.Windows.Forms.DataObject(); data.SetData(System.Windows.Forms.DataFormats.Rtf, myStr.ToString()); System.Windows.Forms.Clipboard.SetDataObject(data, true); System.Windows.Forms.MessageBox.Show("好了,你可以在MS Word 中粘贴文本了."); }