1、需求
遇到大量固定格式的word文档需求录入到系统中。量太打,决定用程序来导入。
2、选用插件Spire
3、实现
因为是固定格式,所以能区到固定格子内的文本就可以了。代码如下
Document doc = new Document(Server.MapPath("file/015010004.doc"));
string str = "";
foreach (Section section in doc.Sections)
{
foreach (Spire.Doc.Table table in section.Tables)
{
foreach (Spire.Doc.TableRow row in table.Rows)
{
Spire.Doc.Collections.ParagraphCollection para = row.Cells[0].Paragraphs;
var a = para[0].Text;
}
}
}