Cita:
Empezado por ContraVeneno
Código Delphi [-] Excel:=CreateOleObject('Excel.Application'); Excel.Visible := False; Excel.DisplayAlerts:= False; Excel.WorkBooks.Add; Excel.WorkBooks[1].WorkSheets[1].Name := 'Libro'; Libro := Excel.WorkBooks[1].WorkSheets['Libro']; Libro.Cells[1,1]:='Reporte'; Libro.Cells[4,1].Font.Bold:=True; Libro.Columns.Columns[2].ColumnWidth := 50; with UnQuery do begin first; Libro.Cells[i,1]:=FieldByname('UnCampo').AsString; Libro.Cells[i,1].Font.Bold:=True; while not EOF Do begin Libro.Cells[i,1]:=FieldByName('OtroCampo').AsString; ..... Next; end; //while end; //with
|
salu2 contraveneno tarté de completar el código y me quedó así:
el código 1ero que nada lo puse dentro de un tbuton, agregue un componente texcelapplication
Código Delphi
[-]
procedure TForm48.Button1Click(Sender: TObject);
var
libro: ExcelApplication;
begin
ExcelApplication1:=CreateOleObject('Excel1.Application');
ExcelApplication1.Visible := False;
ExcelApplication1.DisplayAlerts:= False;
ExcelApplication1.WorkBooks.Add;
ExcelApplication1.WorkBooks[1].WorkSheets[1].Name := 'Libro';
Libro:= ExcelApplication1.WorkBooks[1].WorkSheets['Libro'];
Libro.Cells[1,1]:='Reporte';
Libro.Cells[4,1].Font.Bold:=True;
Libro.Columns.Columns[2].ColumnWidth := 50;
with Query1 do begin
first;
Libro.Cells[i,1]:=FieldByname('numero').AsString;
Libro.Cells[i,1].Font.Bold:=True;
while not EOF Do begin
Libro.Cells[i,1]:=FieldByName('cod_emp').AsString;
Next;
end; end;
y mira los errores que me da :S