1 使用详解
1.1 GetChild()
说明:得到指定节点的子节点。
语法:public Node GetChild(NodeType nodeType, int index, bool isDeep);
可选值:
(1)NodeType.Table,5,节点类型为表格。
(2)NodeType.Row ,6,节点类型为行。
(3)NodeType.Cell ,7,节点类型为单元格。
1.2 ToTxt()
说明:得到指定节点的内容。
语法:public string ToTxt();
注:获取的单元格内容末尾会带有'\r\n'。
1.3 GetText()
说明:得到指定节点的内容。
语法:public string GetText();
注:获取的单元格内容末尾会带有'\a'。
2 获取表格中单元格的内容(使用ToTxt())
using Aspose.Words;
using Aspose.Words.Tables;
Document doc=new Document("c:/test.doc");
DocumentBuilder builder =new DocumentBuiler();
int tableIndex=0;//表格索引,第一个表格
int rowIndex=0;//行索引,第一行
int colIndext=0;//列索引,第一列
//得到文档中的第一个表格
Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
//第一行第一列单元格
Cell cell=table.Rows[rowIndex].Cells[colIndex];
//单元格