Como verificar qual é o nome da "Aba" (Sheet$) da planilha Excel antes de realizar a importação pro SQL
?
Meu código até agora:
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();
}