I have a word document with multiple tables.
From those tables I need to extract the text from the first cell of the first row(so top left text of every table) and add it into a list. I have tried doing this but I can’t get it to work.
You can build logic on the following C# code of Aspose.Words for .NET API to extract Text representations of first Cells of first Rows of all Tables in Word document:
Document doc = new Document("C:\\Temp\\Testcases - documentatie\\5- Testcases - documentatie.docx");
ArrayList textsOfTables = new ArrayList();
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
textsOfTables.Add(table.FirstRow.FirstCell.ToString(SaveFormat.Text));
// Lets write extracted text of tables into a new document
DocumentBuilder builder = new DocumentBuilder();
foreach (string str in textsOfTables)
{
builder.Writeln(str);
builder.InsertBreak(BreakType.SectionBreakNewPage);
}
builder.Document.Save("C:\\temp\\Testcases - documentatie\\21.1.docx");
Thank you for your help, this does kind of work. But for some reason it won’t get more than three tables from the document. this also happend when I was trying.
The problem simply occurs because you seem to be using Aspose.Words for .NET in evaluation mode (i.e. without applying a license). If you want to test ‘Aspose.Words for .NET’ without the evaluation version limitations, then you can also request a 30-day Temporary License. Please refer to How to get a Temporary License?
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.