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

Free Support Forum - aspose.com

Finding Tables in existing documents

Hi,


im using Aspose.Words for a couple of days now and i need to find tables in already existing documents to format them all in the same way. I don´t want to open any of these documents manually.
Is there any possible way to search an document for tables and then do something with them?

Many thanks in advance :slight_smile:

Greetings,
Crazkur

Edit:
At the moment i am trying this to delete all rows except the first:
foreach (Table table in doc.GetChildNodes(NodeType.Table, false))
{
for (int i = 1; i < table.Rows.Count; i++)
{
table.Rows[i].Remove();
}
}
But the foreach never enters, as doc.GetChildNodes doesnt find anything


Hi Crazkur,


Please try using the following code:

Document doc = new Document(MyDir + @“in.docx”);

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))

{

for (int i = 0; i < table.Rows.Count; i++)

{

table.LastRow.Remove();

}

}

doc.Save(MyDir + @"16.12.0.docx");


In case the problem still remains, please attach your input and expected Word documents here for testing. We will investigate the issue on our end and provide you more information.

Bets regards,

Thanks. Works perfectly :slight_smile: