Update specific cell of excel file using oledb

拟墨画扇 提交于 2019-12-20 06:42:53

问题


I want to update the specific cell of the excel file using oledb. Say I7 cell, for some reason always I1 is getting updated. Can anyone tell me what's wrong with this code?

OleDbConnection oledbConn = new OleDbConnection(connString);
oledbConn.Open();

// I want to set the value of I7 cell to 22, for some reason value is I1 is getting updated :(
OleDbCommand cmd = new OleDbCommand("UPDATE [" + sheetName + "$I7:I7] SET F1=22", oledbConn);
int result = cmd.ExecuteNonQuery();
Console.WriteLine(result);
oledbConn.Close();

回答1:


This may purely be an issue with the cell address scheme you're using. Try $I$7:$I$7 intsead. Also, what is that F1 thing in the query?




回答2:


I ran the same program on excel 2007, it worked smoothly. For excel 2013 it does not work. Seems like a bug in excel 2013.



来源:https://stackoverflow.com/questions/15894628/update-specific-cell-of-excel-file-using-oledb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!