Aspose.Word odes not always recognize table in the Word doc

Hi – I am trying to read tables from the Word file. Somtimes ASPOSE does to see the table. Can anybosy help? Here is the code I am using:

public static System.Collections.Generic.List<Row> GetRows(Stream ioStream)
{
    //Return a collection of rows.
    //Sometimes its necessary to parse ahead to the next row but this is hard to do if the next row may or may 
    //not be in the next table. Pushing all of the rows into a single row collection solves the problem.
    ArrayList alist = new ArrayList();
    Aspose.Words.Table tbl; System.Collections.Generic.
        List<Row> rows = new System.Collections.Generic.List<Row>();
    if (ioStream.Length == 0) return (null); Aspose.Words.
        Document doc = new Document(ioStream);
    for (int n = 0; n < doc.Sections.Count; n++) //for each section
    {
        for (int i = 0; i < doc.Sections[n].Body.Tables.Count; i++) //for each table
        {
            tbl = doc.Sections[n].Body.Tables[i];
            for (int j = 0; j < tbl.Rows.Count; j++) // for each row
            {
                rows.Add(tbl.Rows[j]);
            }
        }
    }
    return rows;
}

This message was posted using Aspose.Live 2 Forum

Hi
Thank you for your interest in Aspose.Words. I think that you can achieve this using the following line of code.

NodeCollection rows = doc.GetChildNodes(NodeType.Row, true);

Also please attach your document here for testing. I will try to reproduce your problem and provide you more information.
Best regards.

Hi – Thanks for the resopnse! I tried the solution you offered, but with the same results – Count=0;
I am attaching the document, please, look at it.
Thanks, Vladimir.

Hi
Thanks for additional information. I can’t reproduce this problem. I tried this code

Document doc = new Document(@"Test023\in.doc");
NodeCollection rows = doc.GetChildNodes(NodeType.Row, true);
int count = rows.Count; //returns 55

Maybe you should try to use the latest version of Aspose.Words.
https://releases.aspose.com/words/net
Best regards.

Thanks, Alexey. I downloaded the latest version, added as a reference and immediately got this compilation error:
Error 1 ‘System.Data.SqlClient.Row’ is inaccessible due to its protection level C:\Projects\AMLCFT.v01\App_Code\Utils.cs 566 51 C:\Projects\AMLCFT.v01
in

public static System.Collections.Generic.List GetRows(Stream ioStream)
{
    //Return a collection of rows.
    //Sometimes its necessary to parse ahead to the next row but this is hard to do if the next row may or may 
    //not be in the next table. Pushing all of the rows into a single row collection solves the problem.
    ArrayList alist = new ArrayList();
    Aspose.Words.Table tbl;
    System.Collections.Generic.List rows = new System.Collections.Generic.List();
    if (ioStream.Length == 0) return (null);
    Aspose.Words.Document doc = new Document(ioStream);
    for (int n = 0; n < doc.Sections.Count; n++) //for each section
    {
        for (int i = 0; i < doc.Sections[n].Body.Tables.Count; i++) //for each table
        {
            tbl = doc.Sections[n].Body.Tables[i];
            for (int j = 0; j < tbl.Rows.Count; j++) // for each row
            {
                rows.Add(tbl.Rows[j]);
            }
        }
    }
    return rows;
}

Please, advise.
Thanks, Vladimir.

Never mind, Alexey – I got it, you, guys, changed classes structure.
Thanks, Vladimir

Alexey – I upgraded to version 5 and ran your code in a test project:

Document doc = new Document(@"C:\Uganda.DOC");
NodeCollection rows = doc.GetChildNodes(NodeType.Row, true);
int count = rows.Count; //returns 0

Still 0 rows :frowning:
Any ideas?
Thanks, Vlad.

Hi
Unfortunately I can’t reproduce this on my side. Maybe you can create sample application that will allow me seeing the problem.
Best regards.

Hi Alexey – I am attaching a zipped project and a test file.
Thanks, Vladimir.

Here is the test file.

Hi
This occurs because you use trial version of Aspose.Words. Evaluation version of Aspose.Words (without a license specified) provides full product functionality, but it injects an evaluation watermark at the top of the document on open and save and limits the maximum document size to several hundred paragraphs.
If you want to test Aspose.Words without evaluation version limitations, you can also request a 30-Day Temporary License. Please refer to
https://purchase.aspose.com/temporary-license
Best regards.

Alexey – I added our license file to the project with the same result: 0 nodes.
I am attaching a project file.
Thanks, VLadimir.

Hi
Thanks fro additional information.

  1. You should apply your license using the following code.
License lic = new License();
lic.SetLicense("Aspose.Words.lic");
  1. Your license is expired 30.11.2007.

Best regards.

Thanks, Alexey – I replaced a license with the new one and it worked!
Thanks, Vladimir.