I have the following code to open my Excel Worksheet, using TADOConnection and TADOQuery:
conExcel.ConnectionString := 'Provider=Microsoft.JET.OLEDB.4.0;Data Source="D:\temp\file.xls";Extended Properties="Excel 8.0;HDR=No"';
conExcel.Connected := true;
When I run the following code:
queryExcel1.SQL.Text := 'SELECT * FROM [Hoja1$]';
queryExcel1.Open;
while not queryExcel1.eof do
begin
showmessage(queryExcel1.Fields.Fields[0].AsString);
queryExcel1.Next;
end;
I get each line of the file, so it is working ok, but I want to update a cell. I am using this code:
queryExcel2.SQL.Text := 'UPDATE [Hoja1$] SET F1 = 555555';
queryExcel2.ExecSQL;
Which somehow updates every "A" cell on the worksheet to 555555, but what I really want is to just set the A1 cell to 555555. Any hints on how to include the WHERE section of the query. Thanks.