#region excel格式
string strconn;
strconn = "provider=microsoft.jet.oledb.4.0;"
+ "data source=" + filename + ";"
+ "extended properties=excel 8.0;";
oledbconnection myoledbconnection = new oledbconnection(strconn);
oledbcommand myoledbcommand = new oledbcommand("select * from [sheet1$]", myoledbconnection);
oledbdataadapter mydata = new oledbdataadapter(myoledbcommand);
dataset ds = new dataset();
trycatch (exception ex)
#endregion
#region access格式
string strconn;
strconn = "provider=microsoft.jet.oledb.4.0;"
+ "data source=" + filename + ";";
oledbconnection myoledbconnection = new oledbconnection(strconn);
oledbcommand myoledbcommand = new oledbcommand("select * from aa", myoledbconnection);
oledbdataadapter mydata = new oledbdataadapter(myoledbcommand);
dataset ds = new dataset();
trycatch (exception ex)
#endregion
匯入Excel資料至Access
private void getexcelsheetsbyupload string strexcelpath oledbconn new oledbconnection connstring oledbconn.open 取得到包含資料架構的資料表 dt oledbconn.getoledbsch...
SQL讀取非本地excel或mdb檔
近期由於文件管理的需要,統一將上傳檔案存放至一台專的檔案主機,但是這樣一來由於文件與sqlserver不在同一主機,使得原來的上傳excel和mdb檔的匯入資料功能不能執行,原因是sqlserver不能直接讀取非本地的文件.查詢了一下資料,在sqlserver裡使用 xp cmdshell 執行ne...
excel操作 讀取excel
讀取excel步驟 匯入xlrd模組 開啟excel 讀取需要的sheet頁 通過sheet頁編號或者sheet名字 獲取該sheet頁每行每個字段結果 import xlrd book xlrd.open workbook students.xls 開啟excel sheet book.sheet...