How do I write to specific cells in Excel?
This works for writing to cells that have the titles "id" and "name" in the first row.
string stSheetName = "Sheet1";
string sql = "Insert into [" + stSheetName + "$] (id,name) values('5','e')";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
This does not work:
string sql = "Insert into [" + stSheetName + "$A2:B2] SET A2 = '5', B2 = 'e'";
This works for writing to cells that have the titles "id" and "name" in the first row.
string stSheetName = "Sheet1";
string sql = "Insert into [" + stSheetName + "$] (id,name) values('5','e')";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
This does not work:
string sql = "Insert into [" + stSheetName + "$A2:B2] SET A2 = '5', B2 = 'e'";
bhs67
No comments:
Post a Comment