A
amol_p11
Guest
Hi ,
i am trying to update a particular cell of excel through oledb, following is my code
OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();
builder.Provider = "Microsoft.ACE.OLEDB.12.0";
builder.DataSource = "D:\\Automation Template v0 8.xlsx";
builder["Extended Properties"] = "Excel 12.0;HDR=NO;";
OleDbConnection con = new OleDbConnection(builder.ConnectionString);
string val="xyz";
con.Open();
OleDbCommand objCmdSelect = new OleDbCommand();
objCmdSelect.Connection = con;
objCmdSelect.CommandText ="UPDATE [Input Sheet$C14:C14] SET F1=" + "'" + val + "'";
objCmdSelect.ExecuteNonQuery();
con.Close();
With this codeThe cell C14 is getting updated but the value seen in the cell is 'xyz which should be xyz.
I also tried objCmdSelect.CommandText = "UPDATE [Input Sheet$C14:C14] SET F1='xyz'";
but same thing was observed.
even for integer values objCmdSelect.CommandText = "UPDATE [Input Sheet$C14:C14] SET F1='123'"; simmilar issue is observed.
Please can some one give a suggestion on this...? or is there any alternative method for this..?
Continue reading...
i am trying to update a particular cell of excel through oledb, following is my code
OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();
builder.Provider = "Microsoft.ACE.OLEDB.12.0";
builder.DataSource = "D:\\Automation Template v0 8.xlsx";
builder["Extended Properties"] = "Excel 12.0;HDR=NO;";
OleDbConnection con = new OleDbConnection(builder.ConnectionString);
string val="xyz";
con.Open();
OleDbCommand objCmdSelect = new OleDbCommand();
objCmdSelect.Connection = con;
objCmdSelect.CommandText ="UPDATE [Input Sheet$C14:C14] SET F1=" + "'" + val + "'";
objCmdSelect.ExecuteNonQuery();
con.Close();
With this codeThe cell C14 is getting updated but the value seen in the cell is 'xyz which should be xyz.
I also tried objCmdSelect.CommandText = "UPDATE [Input Sheet$C14:C14] SET F1='xyz'";
but same thing was observed.
even for integer values objCmdSelect.CommandText = "UPDATE [Input Sheet$C14:C14] SET F1='123'"; simmilar issue is observed.
Please can some one give a suggestion on this...? or is there any alternative method for this..?
Continue reading...