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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -