Hi Firuz,
Please refer below code
C#
Word.Application word = new Word.Application();
Word.Document doc = new Word.Document();
object filePath = Server.MapPath("~/Files/CustomerID.docx");
object missing = System.Type.Missing;
try
{
doc = word.Documents.Open(ref filePath, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
DataTable dt = new DataTable();
DataRow dr;
dr = dt.NewRow();
StringBuilder sb = new StringBuilder();
sb.Append("<table border='1'><tr>");
sb.Append("</tr>");
foreach (Word.Row tableRow in word.Application.ActiveDocument.Tables[1].Rows)
{
sb.Append("<tr>");
for (int i = 1; i <= tableRow.Cells.Count; i++)
{
sb.Append("<td>" + tableRow.Cells[i].Range.Text.Replace("\r\a", "").Trim() + "</td>");
}
sb.Append("</tr>");
}
sb.Append("</table>");
txtData1.Text = sb.ToString(); // Bind sb to your RichTextBox so that it would show data in table format.
}
catch (Exception ex)
{
}
finally
{
((Word._Application)word).Quit();
}
Hope this works for you