好。我在这里找到了解决方案。
最终代码如下:
Application word = new Application();document doc = new document();object fileName = path;// Define an object to pass to the API for missing parametersobject missing = System.Type.Missing;doc = word.documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);String read = string.Empty;List<string> data = new List<string>();for (int i = 0; i < doc.Paragraphs.Count; i++){ string temp = doc.Paragraphs[i + 1].Range.Text.Trim(); if (temp != string.Empty) data.Add(temp);}((_document)doc).Close();((_Application)word).Quit();GridView1.DataSource = data;GridView1.DataBind();
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)