c# - How do I write to specific cells in Excel? -
how write specific cells in excel?
this works writing cells have titles "id" , "name" in first row.
string stsheetname = "sheet1"; string sql = "insert [" + stsheetname + "$] (id,name) values('5','e')"; mycommand.commandtext = sql; mycommand.executenonquery();
this not work:
string sql = "insert [" + stsheetname + "$a2:b2] set a2 = '5', b2 = 'e'";
i found problem. (oledbconnection) hdr=yes must hdr=no. following work.
string sql = "update [" + stsheetname + "$b2:b2] set f1='e'";
Comments
Post a Comment