I need to write an sql query (in c#) to select excel sheet data in only the “C” column starting from C19. But i cant specify the ending cell number because more data are getting added to the column. Hence i need to know how to specify the end of the column. Please help. I have mentioned the query that i’m using. And I have attached an image of the excel sheet that i’m using!.And I have attached the output datagridview!
//Generte Oracle Datatable
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;"
+ @"Data Source=" + textBox1.Text + ";" + @"Extended Properties=""Excel 12.0 Macro;HDR=Yes""");
conn.Open();
OleDbCommand ccmd = new OleDbCommand(@"Select * From [SPAT$]", conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(ccmd);
DataTable Oracle = new DataTable();
adapter.Fill(Oracle);
for (int y = 19; y < Oracle.Rows.Count; y++)
{
var value = Oracle.Rows[y][3].ToString();
}
dataGridView1.DataSource = Oracle.AsEnumerable().Where((row, index) => index > 3).CopyToDataTable();
First Approach, using OLE Query:
For criteria based DataTable
For Column “C” only
Second Approach, using Excel COM object: