asp.net传数据到execl文件的问题
我在asp.net(C#)中用"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("\\") + filename + ";" + "Extended Properties=Excel 8.0;"打开指的execl文件,然后往指定的单元格赋值.比如我要往execl文件中的第3行,第一列赋值.如何写呢.....写完后就直接打印,最后不保存退出execl.我的部分源码如下:红色部分如何写呢:
string mystring = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("\\") + filename + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = mystring;
//打开连接
conn.Open();
string sql = "Update [sheet1$] set f1='1212122',f2='wwwwww' where hasnumber='1'"; OleDbCommand olecommand = new OleDbCommand(sql, conn);
//执行语句
olecommand.ExecuteNonQuery();
conn.Close();