Monday, September 2, 2013

Get Table from Word Document Asp.Net C#

for (int t = 1; t < doc.Tables.Count; t++)
        {
            DataTable dt = new DataTable();
            DataRow dr = dt.NewRow();
            int col = doc.Tables[t].Columns.Count;
            int row = doc.Tables[t].Rows.Count;
            for (int i = 1; i <= col; i++)
            {
                                   dt.Columns.Add(doc.Tables[t].Columns[i].Cells[1].Range.Text);
              }
               

            }
            for (int r = 2; r <= row; r++)
            {
                dr = dt.NewRow();
                dt.Rows.Add(dr);
                for (int c = 1; c <= col; c++)
                {
                                  dr[doc.Tables[t].Columns[c].Cells[1].Range.Text] = doc.Tables[t].Rows[r].Cells[c].Range.Text.Trim();
                    }
                                   
                }
            }

        }

No comments:

Post a Comment

Complete Authentication System in ASP.NET Core using JWT

JWT (JSON Web Token) authentication is widely used for securing APIs in modern applications. In this article, we will build a complete authe...