var
Excel:variant;
procedure tnumeracion.exportarobra;
var
Texto:String;
i,j:integer;
begin
try
Excel := CreateOleObject('Excel.Application');
except
begin
showmessage('No se pudo crear el Objecto Excel.');
Exit;
end;
end;
//------------ abre LA HOJA 1 DE EXCEL
Excel.Workbooks.Open('C:\almacenc333\exportarexcel\Obras.xls');
//------ CONVERSION
i:=2;
dmtablas.verobras.first;
while not dmtablas.verObras.eof do
begin
Excel.Cells[i,1].Value:=dmtablas.verObras.Fields[0].AsInteger ;
Excel.Cells[i,2].Value:=dmtablas.verObras.Fields[1].AsInteger;
dmtablas.verObras.Next;
i:=i+1;
end;
if not cancela then
showmessage('Operación finalizada')
else
showmessage('Operación Cancelada');
//--------- cierra el archivo
try
begin
excel.displayalerts:=false; {no muestra el mensaje confirmando grabar}
excel.save;
excel.quit;
end
except
begin
showmessage('La aplicación Excel no se pudo finalizar automaticamente.');
Excel.Visible := True;
end;
end;
excel := Unassigned; {libera objeto OLE
end; {exportarobras}
Hay otra forma y es usando la paleta SERVERS, los componentes son ExcelAplication, ExcelWorkbook y excelWorksheet
Y el procedimiento sería mas o menos así
Procedure xxx
Var template, newtemplate, itemindex:o