C# NPOI
2021-03-05 00:25
标签:ocx string foreach project void stream cto ring str Nuget安装 C# NPOI 标签:ocx string foreach project void stream cto ring str 原文地址:https://www.cnblogs.com/tangpeng97/p/14468489.htmlC# NPOI
Word
环境准备
引用
using NPOI.HWPF;
using NPOI.HWPF.Extractor;
读取word文件
static void NPOIReadWord() {
string path = @"D:\Project\NPOI_文本对比\PDF\1-太平粤港澳大湾区终身重大疾病保险条款.doc";
using (StreamReader streamReader = new StreamReader(path))
{
var document = new HWPFDocument(streamReader.BaseStream);
var wordExtractor = new WordExtractor(document);
var docText = new StringBuilder();
foreach (string text in wordExtractor.ParagraphText)
{
Console.WriteLine(text.Trim());
}
streamReader.Close();
}
}