Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

Not able to update cell in excel woksheet using oledb connection

$
0
0

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.


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>