chetan Allipur

chetan Allipur

  • NA
  • 541
  • 167.6k

I am not getting all rows from the document file

Apr 6 2017 3:30 AM
I am extracting all rows from the document file and binding to the grid using Aspose(word).But It is not taking all rows from the document. I want all rows from the Document.
 
Here is my Code-
 
Document doc = new Document(txtFilePath.Text);
// Retrieve the first table in the document.
Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
//// Create a clone of the table.
Aspose.Words.Tables.Table tableClone = (Aspose.Words.Tables.Table)table.Clone(true);
foreach (Row tblrow in tableClone)
{
if (tblrow.Cells[0].ToTxt().Trim() != "Reference Number")
{
DataRow dr = dtable.NewRow();
string col1 = tblrow.Cells[0].ToTxt().Trim();
string col2 = tblrow.Cells[1].ToTxt().Trim();
dr["Reference Number"] = col1;
dr["Serial Number"] = col2;
//
string col3 = tblrow.Cells[2].Range.Text; //tblrow.Cells[2].ToTxt().Trim(); //tblrow.Cells[2].Range.FormFields[0].Result
string s = col3;
string testchar = "";
string sTo = tblrow.Cells[2].Range.Text.Split((char)19)[1].Substring(tblrow.Cells[2].Range.Text.Split((char)19)[1].IndexOf("FORMTEXT To:") + 16).Trim();
string sFrom = tblrow.Cells[2].Range.Text.Split((char)19)[2].Substring(tblrow.Cells[2].Range.Text.Split((char)19)[2].IndexOf("FORMTEXT From:") + 17).Trim();
string sDate = tblrow.Cells[2].Range.Text.Split((char)19)[3].Substring(tblrow.Cells[2].Range.Text.Split((char)19)[3].IndexOf("FORMTEXT Date:") + 17).Trim();
string sForm = tblrow.Cells[2].Range.Text.Split((char)19)[4].Substring(tblrow.Cells[2].Range.Text.Split((char)19)[4].IndexOf("FORMTEXT Form:") + 17).Trim();
string sRe = tblrow.Cells[2].Range.Text.Split((char)19)[5].Substring(tblrow.Cells[2].Range.Text.Split((char)19)[5].IndexOf("FORMTEXT Re:") + 15).Trim();
dr["To"] = sTo.Replace((char)21, ' ').Trim();
dr["From"] = sFrom.Replace((char)21, ' ').Trim();
dr["Date"] = sDate.Replace((char)21, ' ').Trim();
dr["Form"] = sForm.Replace((char)21, ' ').Trim();
dr["Re"] = sRe.Replace((char)21, ' ').Replace('\a', ' ').Trim();
dtable.Rows.Add(dr);
}
}