public DataTable ExcelToDataSet(string filename, string[] templateNames)
{
DataTable dataTable = new DataTable();
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Extended Properties=Excel 8.0;" +
"data source=" + filename;
OleDbConnection myConn = new OleDbConnection(strCon);
foreach (string tempName in templateNames)
{
DataTable dataTableTemp = new DataTable();
string strCom = " SELECT * FROM [" + tempName + "$]";
myConn.Open();
OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
myCommand.Fill(dataTableTemp);
myConn.Close();
dataTable.Merge(dataTableTemp);
}
return dataTable;
}