NicolasDeMarco
MIS
First: sorry for my english:
I create a new sheet into an Excel Worksheet using an ADOConnection (pointing the file with Microsoft Jet OLE DB Provider).
Connection.ConnectionString :=
'Provider=Microsoft.Jet.OLEDB.4.0;' +
'Extended Properties="Excel 8.0;HDR=Yes;";' +
'Data Source="' + Trim(FileName) + '"';
I use an empty Excel Worksheet wiht an only tabsheet. Of course I cannot create an Excel Worksheet with no tabsheets.
The way to create the NEW sheet was executing a TADOQuery.Execute "CREATE TABLE Tablename, etc....". Then I create the rows executing a TADOQuery.Execute "INSERT INTO Tablename (col1, col2, col3) VALUES (value1, value2, value3)". That's all OK.
When I tried to delete the original sheet (Sheet1) using the following TADOQuery.Execute "DROP TABLE Sheet1". I received the response "Table does not exists".
I get the contents of the database (worksheet) with the following code, but it does not work:
// Code
List := TStringList.Create;
Connection.GetTableNames(List, False);
ADOQry.Close;
for i := 0 to List.Count - 1 do begin
if (Trim(List) <> 'Tablename') then
begin
ADOQry.SQL.Text := 'DROP TABLE [' +
StringReplace(Trim(Listatablas), '$', '', [rfReplaceAll]) + ']';
ADOQry.Execute;
end;
end;
List.Free;
// I tried with ('[',']') and without ('[',']')
If somebody has an answer I will appreciate.
Nicolas
I create a new sheet into an Excel Worksheet using an ADOConnection (pointing the file with Microsoft Jet OLE DB Provider).
Connection.ConnectionString :=
'Provider=Microsoft.Jet.OLEDB.4.0;' +
'Extended Properties="Excel 8.0;HDR=Yes;";' +
'Data Source="' + Trim(FileName) + '"';
I use an empty Excel Worksheet wiht an only tabsheet. Of course I cannot create an Excel Worksheet with no tabsheets.
The way to create the NEW sheet was executing a TADOQuery.Execute "CREATE TABLE Tablename, etc....". Then I create the rows executing a TADOQuery.Execute "INSERT INTO Tablename (col1, col2, col3) VALUES (value1, value2, value3)". That's all OK.
When I tried to delete the original sheet (Sheet1) using the following TADOQuery.Execute "DROP TABLE Sheet1". I received the response "Table does not exists".
I get the contents of the database (worksheet) with the following code, but it does not work:
// Code
List := TStringList.Create;
Connection.GetTableNames(List, False);
ADOQry.Close;
for i := 0 to List.Count - 1 do begin
if (Trim(List) <> 'Tablename') then
begin
ADOQry.SQL.Text := 'DROP TABLE [' +
StringReplace(Trim(Listatablas), '$', '', [rfReplaceAll]) + ']';
ADOQry.Execute;
end;
end;
List.Free;
// I tried with ('[',']') and without ('[',']')
If somebody has an answer I will appreciate.
Nicolas