为您找到"
c#如何将word文档中的内容读取到richtextbox控件中
"相关结果约100,000,000个
private string ReadWord(string path){ Document doc = new Document(path);using (MemoryStream ms = new MemoryStream()){ doc.SaveOptions.HtmlExportImagesFolder= "temp/"; //debug下建个temp目录用于存图片。doc.Save(ms, SaveFormat.Html);string text = Encoding.UTF8.GetString(ms.ToArr...
private string ReadWord(string path){ Document doc = new Document(path);using (MemoryStream ms = new MemoryStream()){ doc.SaveOptions.HtmlExportImagesFolder= "temp/"; //debug下建个temp目录用于存图片。doc.Save(ms, SaveFormat.Html);string text = Encoding.UTF8.GetString(ms.To...
richTextBox1.Text= ss.ReadToEnd();//在richTextBox1里面显示 }
Word 文档要是能用 RichTextBox 读取,那我可以写个 简易版 Word 了。转换成 RTF 格式再读取吧 可能 Word 的 Rtf 格式和 .NET 的 Rtf 格式不同吧。LoadFile 有很多参数你都试试了吗?另外本来 Rtf 就和 Word 不同,如果强求格式一致有点过分了吧 ...
是的话,我说一点,先定义一个公开的变量用来存储复制的文字,来获取这些文字后,再给另一个文本框赋值就OK了.public static string str;private void button1_Click(object sender, EventArgs e){ str = richTextBox1.SelectedText;//复制 } private void button2_Click(object sender, EventArgs e){...
根据文本文件内容的行数,动态加载TextBox并在每个TextBox中显示一行内容。实现方法如下:(1)在Visutal Studio中新建一个“Windows应用程序”(2)在Form1上布置一个Button (3)窗体代码 Form1.cs using System;using System.Windows.Forms;using System.IO;namespace WindowsFormsApplication6{ publ...
//用richTextBox打开带格式的word文档 //先打开word文档,全选其中的内容并保存的剪切板中,最后在richTextBox中粘贴数据,并关闭文档 public void OpenWord(string fileName) { //C#读取word文件 Microsoft.Office.Interop.Word.ApplicationClass app = new ApplicationClass(); Microsoft...
richTextBox,把读取的Word的Rtf赋值给richTextBox的rtf就行了
用openFileDialog控件 if (openFileDialog1.ShowDialog() == DialogResult.OK){ System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName,Encoding.Default);richTextBox1.Text = sr.ReadToEnd();sr.Close();}
方法可以给你 internal void FindText(RichTextBox rtb, string text){ rtb.HideSelection = false;int searchStartPosition = rtb.SelectionStart;if (rtb.SelectedText.Length > 0){ searchStartPosition = rtb.SelectionStart + rtb.SelectedText.Length;} int indexOfText = rtb.Find(text, search...