Free Support Forum - aspose.com

Reading a table from a word doc

When Aspose words retreives a table form a word document, it returns a long string of all the table content. Is it possible to load the table data with spaces between cells?

Hi,


Thanks for your inquiry. Unfortunately, I have not completely understood your query. Perhaps, you want to get the contents of table’s cell.

The CompositeNode.GetChildNodes returns a live collection of child nodes that match the specified type. The NodeType specifies the type of a Word document node. Please use CompositeNode.GetChildNodes with NodeType.Cell to get the collection of table’s cell as shown in following code snippet.

You can get the text of each cell by using following code snippet.

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> doc = new Document(MyDir

  • “table.docx”);<o:p></o:p>

Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

foreach (Cell cell in table.GetChildNodes(NodeType.Cell, true))

{

Console.Write(cell.GetText());

}


Hope this answers your query. If this does not help you, please share some more information about your query.