Document document = new Document();
document.LoadFromFile("F:\\Zhang\\Mission\\8\\8.11\\TEST.docx");
Section section = document.Sections[0];
Table table = section.Tables[0] as Table;
// 遍历表格的每一行
for (int rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++)
{
TableRow row = table.Rows[rowIndex];
// 遍历当前行的每个单元格
for (int cellIndex = 0; cellIndex < row.Cells.Count; cellIndex++)
{
TableCell cell = row.Cells[cellIndex];
//遍历所有段落
for (int i = 0; i < cell.Paragraphs.Count; i++)
{ // 获取单元格的内容
string content = cell.Paragraphs[i].Text;
}
}
}