How to check the name of the "Sheet" of the Excel worksheet before performing the% pro SQL
?
My code so far:
protected void btnProcessar_Click(object sender, EventArgs e)
{
string path = Server.MapPath(".") + "\" + FileUpload.FileName;
this.ImportarArquivoExcel(path);
}
private void conexaoExcel(string path)
{
connectionExcel = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES;""", FilePath);
excelConn = new OleDbConnection(connectionExcel);
}
private void conexaoSQL()
{
connectionSQL = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
sqlConn = new SqlConnection(connectionSQL);
}
public void ImportarArquivoExcel(string path)
{
conexaoExcel(path);
query = string.Format("Select * FROM [{0}]", "DailySalesDetails$");
OleDbCommand Ecom = new OleDbCommand(query, excelConn);
excelConn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter oda = new OleDbDataAdapter(query, excelConn);
excelConn.Close();
oda.Fill(ds);
DataTable Exceldt = ds.Tables[0];
conexaoSQL();
}