Is there a better way than
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=<xlxsName>;Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;ReadOnly=True\"";
string sql = string.Format("SELECT COUNT (*) FROM [{0}] ", worksheetName);
using (OleDbConnection conn = new OleDbConnection(connectionString)) {
OleDbCommand cmd = new OleDbCommand(sql, conn);
conn.Open();
totalCount = (int)cmd.ExecuteScalar();
conn.Close();
}
to get a row count from an excel sheet? If possible I'd prefer to use ADO.Net instead of Excel interop