Hi - The following code returns data from a spreadsheet into a grid perfectly [ string excelConnectString = "Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = " + excelFileName + ";" + "Extended Properties = Excel 8.0;";
OleDbConnection objConn = new OleDbConnection(excelConnectString);
OleDbCommand objCmd = new OleDbCommand("Select * From [Accounts$]", objConn);
OleDbDataAdapter objDatAdap = new OleDbDataAdapter();
objDatAdap.SelectCommand = objCmd;
DataSet ds = new DataSet();
objDatAdap.Fill(ds);
fpDataSet_Sheet1.DataSource = ds;//fill a grid with data
]
The spreadsheet I'm using has columns named from A and so on( just standard column names ) and the sheet name is Accounts.
I have a problem with the query ...
[OleDbCommand objCmd = new OleDbCommand("Select * From [Accounts$]", objConn);]
How can I make the query string like this...
"Select ,,SUM from [Accounts$] group by ,"
..so that it returns the results of this query
Note : columnA is A on Sheet , columnB is B on Sheet and columnG is G on Sheet
Other possible Alternatives... 1.I have the data of that excel spread into a DataTable object, how can I query the DataTAble object 2.I read about a DataView object that it can take a table and return the table manipulated according to ( .RowFilter = "where...") , but I don't know how to use the query I want.
-Thanks for help