I am trying to update execl sheet paricular sheet by writing this code:
connExcel.Open(); string SheetName = null; DataTable dtExcelSchema = null; dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); //checking sheet name if (dtExcelSchema.Rows[2]["TABLE_NAME"].ToString().Contains("_xlnm#Database")) { SheetName = dtExcelSchema.Rows[2]["TABLE_NAME"].ToString(); } if (!dtExcelSchema.Rows[2]["TABLE_NAME"].ToString().Contains("_xlnm#Database")) { SheetName = dtExcelSchema.Rows[2]["TABLE_NAME"].ToString(); } dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, SheetName, null }); OleDbCommand cmd = new OleDbCommand("UPDATE [" + SheetName + "] SET F11=22052", connExcel); int result = cmd.ExecuteNonQuery(); Console.WriteLine(result); connExcel.Close();
But this update query is updating the whole column while i just want update particular cell in excel say 'C9' accodring to excel sheet.
Any help will be appreciated.