| 发表于:2007-03-08 10:12:512楼 得分:0 |
dataset mydataset; string strcon = " provider = microsoft.jet.oledb.4.0 ; data source = " + filename + ";extended properties=excel 8.0 "; oledbconnection myconn = new oledbconnection(strcon); string strcom = " select * from [sheet1$] "; myconn.open(); oledbdataadapter mycommand = new oledbdataadapter(strcom, myconn); mydataset = new dataset(); mycommand.fill(mydataset, "[sheet1$] "); myconn.close(); if (mydataset.tables[0].columns.count != 4) { //列数不正确 return null; } | | |
|