怎麼用C#讀取文本文件,然後寫進excl文件?
有懂得嗎?我是小白 不懂
string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = c:\sample.xls;Extended Properties=Excel 8.0" ;
OleDbConnection myConn = new OleDbConnection ( strCon ) ;
string strCom = " SELECT * FROM [Sheet1$] " ;
myConn.Open ( ) ;
file://打開數據鏈接,得到一個數據集
OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ;
file://創建一個 DataSet對象
myDataSet = new DataSet ( ) ;
file://得到自己的DataSet對象
myCommand.Fill ( myDataSet , "[Sheet1$]" ) ;
file://關閉此數據鏈接
myConn.Close ( ) ;