public DataTable objSheetTable;
string strpath=@”C:\myexcel.xlsx”;
string strpath=@”C:\myexcel.xlsx”;
OleDbConnection oledbConn = new OleDbConnection(@”Provider=Microsoft.ACE.OLEDB.12.0;Data Source=” + strpath + “;Extended Properties=’Excel 12.0;HDR=YES;IMEX=1;’;”);
oledbConn.Open();
oledbConn.Open();
objSheetTable = new DataTable();
objSheetTable = oledbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
int intSheetCount = objSheetTable.Rows.Count;
objSheetTable = oledbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
int intSheetCount = objSheetTable.Rows.Count;
for (int intSheet = 0; intSheet < 0; intSheet++)
{
{
dt = new DataTable();
OleDbCommand cmd = new OleDbCommand(“SELECT * FROM [" + objSheetTable.Rows[intSheet][2].ToString() + “]”, oledbConn);
OleDbDataAdapter oleda = new OleDbDataAdapter(cmd);
oleda.Fill(dt);
OleDbCommand cmd = new OleDbCommand(“SELECT * FROM [" + objSheetTable.Rows[intSheet][2].ToString() + “]”, oledbConn);
OleDbDataAdapter oleda = new OleDbDataAdapter(cmd);
oleda.Fill(dt);
//Read all rows values based on column..
foreach (DataRow row in dt.Rows)
{
string c1 = row[0].ToString();
strinf c2 = row[1].ToString();
}
}
foreach (DataRow row in dt.Rows)
{
string c1 = row[0].ToString();
strinf c2 = row[1].ToString();
}
}