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;
}
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.
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;
}
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.