Hi Team,
I am not able to extract the table content from the attached document file. System is escaping the table while parsing the content line by line.
Please have a look and advice.
Thanks in advance.
string text=null;
Document doc = new Document();
doc.LoadFromFile(@"test_spire.docx");
Body body = doc.Sections[0].Body;
foreach (DocumentObject child in body.ChildObjects)
{
foreach (DocumentObject child2 in child.ChildObjects)
{
if (child2.DocumentObjectType.Equals(DocumentObjectType.Table))
{
Table table = child2 as Table;
foreach (TableRow tableRow in table.Rows)
{
foreach (TableCell headerCell in tableRow.Cells)
{
foreach (DocumentObject documentObject in headerCell.ChildObjects)
{
if (documentObject is Paragraph)
{
Paragraph paragraph = documentObject as Paragraph;
text += paragraph.Text + "\t";
}
}
}
text += "\n";
}
}
}
}
File.WriteAllText("Extract.txt", text);