//添加引用:Microsoft.Office.Interop.Word.dll
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
object file = @"E:\1.doc";
object nullobj = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
string text = doc.Content.Text;
doc.Close(ref nullobj, ref nullobj, ref nullobj);
app.Quit(ref nullobj, ref nullobj, ref nullobj);
Regex reg = new Regex(@"(?is)(?<=\bstart\b)(?:(?!\bend\b).)*");
foreach (Match m in reg.Matches(text))
Response.Write(m.Value);
借助Word中的书签获取指定文本
最新推荐文章于 2022-08-14 17:47:28 发布