crazytudou
2020-03-13 17:55:26 +08:00
没用过 Microsoft.Office.Interop.Word (会受运行系统上 office 影响),都是用 NPOI (脱离 office )
先取得 Table tr td,再得到每个列内容有多段落( Paragraphs ),再判断是否网址,是就替换成空字符串
XWPFDocument doc = new XWPFDocument(stream); //docx
var tables = doc.Tables;
foreach (var table in tables)
{
foreach (var row in table.Rows)
{
foreach (var cell in row.GetTableCells())
{
foreach (var para in cell.Paragraphs)
{
//para.Text
//判断是否网址,是就替换成空字符串
}
}
}
}