一.使用OleDb,這個法子好像不大好使.容易讀錯.
引用System.Data.OleDb;
/**//// <summary>
/// 返回Excel數據源
/// </summary>
/// <param name="filename">文件路徑</param>
/// <returns></returns>
static public DataSet ExcelToDataSet(string filename)
{
DataSet ds;
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Extended Properties=Excel 8.0;" +
"data source=" + filename;
OleDbConnection myConn = new OleDbConnection(strCon);
string strCom = " SELECT * FROM [Sheet1$]";
myConn.Open();
OleDbDataAdapter myCommand =