Excel sheet name start with number is not working in asp.net
OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Excel + "; Extended Properties= \"Excel 8.0;HDR=Yes;IMEX=1\";");
connection.Open();
DataTable dt = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (dt != null)
{
string[] excelSheets = new String[dt.Rows.Count];
string sheetname;
sheetname = "";
foreach (DataRow row in dt.Rows)
{
if (row["TABLE_NAME"].ToString().Contains("$"))
{
sheetname = row["TABLE_NAME"].ToString();
//Load the DataTable with Sheet Data so we can get the column header
OleDbCommand oconn = new OleDbCommand("select top 1 * from ["
+ sheetname + StartingColumn + StartReadingFromRow + ":" + EndingColumn + "]", connection);
OleDbDataAdapter adp = new OleDbDataAdapter(oconn);
DataTable dtdata = new DataTable();
adp.Fill(dtdata);
connection.Close();
}
}
}
getting Error This:-
The Microsoft Jet database engine could not find the object ''9286$'A6:O'. Make sure the object exists and that you spell its name and the path name correctly.