日期:2014-05-17 浏览次数:21013 次
修改第一行Name的值为张三 string strComm = "update [Sheet1$] set Name='张三' where id = 1"; OleDbConnection myConn = new OleDbConnection(strConn); myConn.Open(); OleDbCommand com = new OleDbCommand(strComm, myConn); com.ExecuteNonQuery(); myConn.Close();
------解决方案--------------------
MSEXCEL.Application excelapp=new Microsoft.Office.Interop.Excel.Application(); object objOpt = System.Reflection.Missing.Value; MSEXCEL.Workbook exceelDoc = excelapp.Workbooks.Open(this.saveFileDialog1.FileName, objOpt, false, objOpt, objOpt, objOpt, true, objOpt, objOpt, true, objOpt, objOpt, objOpt, objOpt, objOpt); MSEXCEL.Worksheet ws = (MSEXCEL.Worksheet)exceelDoc.Sheets[1]; MSEXCEL.Range r; r = ws.get_Range("I12", "I12");//获得I12,I12单元格 r.Value2=赋值;(想取的单元格的Value2)