public DataTable CreateTable()
{
string FilePath = Server.MapPath("~/Studentlist.xls");
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+FilePath+";Extended Properties=Excel 8.0");
conn.Open();
DataTable dbSchema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,null);
if (dbSchema == null dbSchema.Rows.Count < 1)
{
throw new Exception("Error: Could not determine the name of the first worksheet.");
}
string WorkSheetName = dbSchema.Rows[0]["TABLE_NAME"].ToString();
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [" + WorkSheetName + "]", conn);
DataTable dt = new DataTable();
da.Fill(dt);
conn.Close();
return dt;
}
बलात्कार एक बङी समस्या
9 years ago
No comments:
Post a Comment