Limit on rows returned when retrieving tables from Word

I’m calling the following method to retrieve table data from a Word document

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

If I add rows to a table the function correctly returns the rows I’ve added. However, if I exceed a given number of rows for the set of 4 tables I’m interested in I find that the method doesn’t retrieve all data.It appears that if I add any more than 26 rows overall the above method will not retrieve any further rows. Any suggestions or help would be appreciated.

@nlough

Thanks for your inquiry. Please elaborate your requirement in detail, and you may also find this Working with Tables page useful.

Hi Rizwan - if I attach the relevant word document indicating where it’s seemingly failing would you be able to advise further?

@nlough

Thanks for writing back.
Yes, It will help us to figure out exact issue and investigate it further if there is any bug involved. Therefore we will appreciate it if you share your source and output files along with used sample code.

Templates.zip (120.5 KB)

Hi Rizwan. Code is as follows:

var filename = @“C:\role description template baseline v3 -edit fail.docx”;

using (var stream = System.IO.File.Open(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
Aspose.Words.Document doc = new Aspose.Words.Document(stream);
stream.Close();

foreach (Aspose.Words.Tables.Table table in doc.GetChildNodes(Aspose.Words.NodeType.Table, true))
{
//If you call the above for the two files submitted. You can see that in the fail case that not all the table entries are //returned in the call to doc.GetChildNodes

}

I’ve also attached an image which illustrates the difference between the word documents. When we run the fail document the last table highlighted is not included when we call doc.GetChildNodes

WordDocComparison.PNG (92.5 KB)

Hope this helps. If you need any further information please let me know.

Regrds

Norman

@nlough,

Thanks for writing back with details, according to your shared template documents and shared sample code, we assume that you want to load document and get all tables and then update the second table by inserting dynamic row and you are facing issue when you read updated table rows, here is the code we have successfully read the all tables even after inserting new rows to second table using same template files and also continue reading the second document tables.

string dataDir = RunExamples.GetDataDir_MailMergeAndReporting();
string fileName = "insertrows.docx";
Stream stream = System.IO.File.Open(dataDir + fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
Aspose.Words.Document doc = new Aspose.Words.Document(stream);
stream.Close();

int tablecount = 1;
Console.WriteLine("**** Doc ONE Tables ****");
foreach (Aspose.Words.Tables.Table table in doc.GetChildNodes(Aspose.Words.NodeType.Table, true))
{
    Console.WriteLine("Table Rows: " + table.Rows.Count);
    if (tablecount == 2)
    {
        Console.WriteLine("Inserting New row in Table two");
        table.Rows.Insert(table.Rows.Count - 1, table.Rows[table.Rows.Count - 1].Clone(true));
        Console.WriteLine("Table Rows after Insertion: " + table.Rows.Count);
    }
    tablecount += 1;
}

// continue reading another document for tables
fileName = "insertrows2.docx";
stream = System.IO.File.Open(dataDir + fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
doc = new Aspose.Words.Document(stream);
stream.Close();

Console.WriteLine("**** Doc TWO Tables ****");
foreach (Aspose.Words.Tables.Table table in doc.GetChildNodes(Aspose.Words.NodeType.Table, true))
{
    Console.WriteLine("Table Rows: " + table.Rows.Count);
}

Hi Rizwan

No the files are completely separate. I just want to retrieve the tabular data from the files. I included them both just to show (a) the working example and (b) the failing example. To clarify, example (b) (the fail .docx) does not appear to return all the table rows when I call GetChildNodes - if you assign the return value into a variable you will see that the returned object does not contain all the tabular data thatyou can see in the word document

@nlough,

We have re-produced this issue after manually inserted row in a 4th table and while reading all tables it did not read the 5th table so we have logged this issue in our bug tracking system. The ID of this issue is WORDSNET-16172. Your thread has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

@nlough,

We have further investigated this issue with other scenarios and found this issue only appears while using Aspose.Words for .NET API in evaluation (trial) version, The evaluation (trial) version of Aspose.Words (without a license specified) provides full product functionality, but it inserts an evaluation watermark at the top of the document on open and save, and limits the maximum document size to several hundred paragraphs and data ranges etc.

If you want to test Aspose.Words without the evaluation version limitations, you can also request a 30-day Temporary License. Please refer to How to get a Temporary License?