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. |
Recuerda poner los tags al código fuente, ejemplo:
Gracias :) |
Hola Luis.
Cita:
En la próxima llamada a Button1Click el ciclo while no se ejecutará ya que la condición de salida está satisfecha en la comprobación,
Para reproducir nuevamente el comportamiento del método Button1Click, tenes que fijar el primer registro de la tabla como la fila activa antes de entrar al ciclo while:
Saludos :) |
gracias eficsa eso era muy amable disculpa es muy bajo mi nivel
saludos:D |
La franja horaria es GMT +2. Ahora son las 21:20:45. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi