/// <summary>
/// 传入Excel路径,然后把Excel文件内容转换为dataset
/// </summary>
/// <param name="Path">string Path</param>
/// <returns>DataSet</returns>
public DataSet ExcelToDS(string Path)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + Path + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
string strExcelPSID = "";
string strExcelBox = "";
OleDbDataAdapter myCommand = null;
DataSet ds = null;
strExcelPSID="select * from [Sheet1$]"; //Excel表Sheet1
myCommand = new OleDbDataAdapter(strExcelPSID, strConn);
ds = new DataSet();
myCommand.Fill(ds,"Sheet1");
strExcelBox="select * from [Sheet2$]"; //Excel表Sheet1
myCommand = new OleDbDataAdapter(strExcelBox, strConn);
conn.Close();
myCommand.Fill(ds,"Sheet2");
return ds;
}