/// <summary>
/// Read Excel to DataSet
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
private static DataSet ExcelToDataSet(string filename)
{
DataSet ds;
//HDR=Yes;IMEX=1 HDR隐藏Excel表头 IMEX是以混合模式读取Excel表格数据,防止改变数据类型
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + filename + ";" + "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';";
System.Data.OleDb.OleDbConnection myConn = new System.Data.OleDb.OleDbConnection(strCon);
string strCom = " SELECT * FROM [Sheet1$]";
myConn.Open();
System.Data.OleDb.OleDbDataAdapter myCommand = new System.Data.OleDb.OleDbDataAdapter(strCom, myConn);
ds = new DataSet();
myCommand.Fill(ds);
myConn.Close();
return ds;
}