We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Get Parent Section from Table Object

Hi Support,

I need to identify Section in with Table is contained programaticaly using ASPOSE Word.

I am having ASPOSE.Words.Tables.Table object in hand currently and based on that i want to get

Section in which this Table is contained as Section object.

Please get back asap.


Hi Divesh,

Thanks for the inquiry.

Yes, if you have the Table object, you can get the Section object for that Table using the inherited GetAncestor() method of Node class. Following code snippet should be helpful:
// Get the first table in the document directly.
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
// Get the section parent of the table.
Section tablesSection = (Section)table.GetAncestor(NodeType.Section);

Please have a look at the documentation reference for Section here and for Table here. Hope this helps. Please let us know if you have any more queries.