标签:
private void readFileContent() { string path = @"C:\Users\Lee\Desktop\TI杯设计文档\点滴系统\计划进度.docx"; object file = path; object nullobj = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document wordDocument = wordApplication.Documents.Open( ref file, ref nullobj, Missing.Value, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); wordDocument.ActiveWindow.Selection.WholeStory(); wordDocument.ActiveWindow.Selection.Copy(); IDataObject data = Clipboard.GetDataObject(); richTextBox1.Text = data.GetData(DataFormats.Text).ToString(); //wordDocument.Close(ref nullobj, ref nullobj, ref nullobj); //wordApplication.Quit(ref nullobj, ref nullobj, ref nullobj); }
<pre name="code" class="csharp"> private void readFileContent(){ Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document wordDocument; object unknow = Type.Missing; wordApplication.Visible = false; string str = @"C:\Users\Lee\Desktop\TI杯设计文档\点滴系统\计划进度.docx"; object file = str; wordDocument = wordApplication.Documents.Open(ref file, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow); for (int i = 1; i < wordDocument.Paragraphs.Count; i++) { string temp = wordDocument.Paragraphs[i].Range.Text.Trim(); richTextBox1.AppendText(temp); Console.WriteLine(temp); } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/ilipan/article/details/47379539