Ver Mensaje Individual
  #1  
Antiguo 29-08-2015
luis77 luis77 is offline
Miembro
NULL
 
Registrado: ago 2015
Posts: 20
Reputación: 0
luis77 Va por buen camino
exportar excel

hola buen dia espero alguien me pueda ayudar se los agraderia
tengo el siguiente codigo el cual si me realiza la exportacion
a excel.
el detalle esta en que cuan ejecuto la aplicacion solo le doy click si me extrae los datos
pero cuando quiero volver a dar click ya no .
que me estar faltando.
gracias saludos

procedure TForm1.Button1Click(Sender: TObject);

var i:integer;
PLANILHA, Excel,libro: VARIANT;
LINHA,CONT:INTEGER;
begin
//CONT:=Query.RecordCount;
//ProgressBar1.Max:=CONT;
//ProgressBar1.Position:=0; QUERY.Filtered:=FALSE;
LINHA:=1;
PLANILHA:=CreateOleObject('Excel.Application');
PLANILHA.caption:='Delphi para excel';
PLANILHA.visible:=true;
PLANILHA.workbooks.add(-4167);
//PLANILHA.workbooks[1].WorkSheets[1].name:='Reporte';
//linha:=PLANILHA.WorkBooks[1].WorkSheets['Reporte'];
PLANILHA.cells[1,1]:='Sucursal';
PLANILHA.cells[1,2]:='TipoPrenda';
PLANILHA.cells[1,3]:='Contratos';
PLANILHA.cells[1,4]:='Estatusprenda';
PLANILHA.cells[1,5]:='Descripcion';
PLANILHA.cells[1,6]:='Partida';
PLANILHA.cells[1,7]:='Kilataje';
PLANILHA.cells[1,8]:='Peso';
PLANILHA.cells[1,9]:='PesoNeto';
PLANILHA.cells[1,10]:='ImporteAvaluo';
PLANILHA.cells[1,11]:='ImporteOriginal';
PLANILHA.cells[1,12]:='AbonoAcapital';
PLANILHA.cells[1,13]:='ImportePrestamo';
PLANILHA.cells[1,14]:='FechaContrato';
PLANILHA.cells[1,15]:='Fechavencimiento';


query.DisableControls;

try while not query.Eof do
begin
PLANILHA.cells[linha,1]:=query.FieldByName('Sucursal').AsString;
PLANILHA.cells[linha,2]:=Query.FieldByName('TipoPrenda').AsString;
PLANILHA.cells[linha,3]:=Query.FieldByName('Contratos').AsString;
PLANILHA.cells[linha,4]:=Query.FieldByName('EstatusPrenda').AsString;
PLANILHA.cells[linha,5]:=Query.FieldByName('Descripcion').AsString;
PLANILHA.cells[linha,6]:=Query.FieldByName('Partida').AsString;
PLANILHA.cells[linha,7]:=Query.FieldByName('Kilataje').AsString;
PLANILHA.cells[linha,8]:=Query.FieldByName('Peso').AsString;
PLANILHA.cells[linha,9]:=Query.FieldByName('PesoNeto').AsString;
PLANILHA.cells[linha,10]:=Query.FieldByName('ImporteAvaluo').AsString;
PLANILHA.cells[linha,11]:=Query.FieldByName('ImporteOriginal').AsString;
PLANILHA.cells[linha,12]:=Query.FieldByName('AbonoACapital').AsString;
PLANILHA.cells[linha,13]:=Query.FieldByName('ImportePrestamo').AsString;
PLANILHA.cells[linha,14]:=Query.FieldByName('FechaContrato').AsString;
PLANILHA.cells[linha,15]:=Query.FieldByName('FechaVencimiento').AsString;

LINHA:=linha+1;
query.Next;
// ProgressBar1.Position:=ProgressBar1.Position+1;
end;
PLANILHA.columns.autofit;
planilha.Visible:=true;
finally
Query.EnableControls;
PLANILHA:=Unassigned;
query.Next;
QUERY.ClearFields;
end;


end;

end.
Responder Con Cita