Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Impresión
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 23-07-2003
DanielAlexander DanielAlexander is offline
Miembro
 
Registrado: may 2003
Ubicación: argentina
Posts: 40
Poder: 0
DanielAlexander Va por buen camino
Unhappy Exportación de Qreports a excel

Hola Gente!!!!
necesito ayuda por favor.
Tengo escrito el siguiente codigo, tengo echo un corte de control
por codigo de farmacia para cuando cambie de codigo, me
genere una nueva hoja, con los datos de ese codigo de farmacia
lo que no se como hacer es como agregar una hoja a excel.
Gracias....



try
excel:=CreateOleObject('Excel.Application');
except
ShowMessage('Excel no se pudo iniciar.');
exit;
end;
excel.Visible:=true;
Data:=DBGRID1.DataSource.DataSet;
Data.First;
WorkBook:=Excel.WorkBooks.Add;


hoja:=1;
while not(Data.eof) do
begin
Sheet:=WorkBook.WorkSheets[hoja];
Sheet.Name:=inttostr(Data.FieldByName(DBGrid1.Columns[0].FieldName).asinteger);
Row:=1;
Sheet.Cells[Row,1]:='COD-FAR';
Sheet.Cells[Row,2]:='FARMACIA';
Sheet.Cells[Row,3]:='REMITO';
Sheet.Cells[Row,4]:='RECETA';
Sheet.Cells[Row,5]:='SECUENCIA';
Sheet.Cells[Row,6]:='PRODUCTO';
Sheet.Cells[Row,7]:='IMPORTEOSACEPTADO';
Sheet.Cells[Row,8]:='PERIODO';
Sheet.Cells[Row,9]:='LOCALIDAD';
Sheet.Cells[Row,10]:='IDRECETA';
Sheet.Cells[Row,11]:='NUMERODELINEA';
Sheet.Rows[Row].Font.Bold:=true;
Sheet.Cells[Row,1].font.color:=clred;
Sheet.Cells[Row,2].font.color:=clred;
Sheet.Cells[Row,3].font.color:=clred;
Sheet.Cells[Row,4].font.color:=clred;
Sheet.Cells[Row,5].font.color:=clred;
Sheet.Cells[Row,6].font.color:=clred;
Sheet.Cells[Row,7].font.color:=clred;
Sheet.Cells[Row,8].font.color:=clred;
Sheet.Cells[Row,9].font.color:=clred;
Sheet.Cells[Row,10].font.color:=clred;
Sheet.Cells[Row,11].font.color:=clred;

codfar:=Data.FieldByName(DBGrid1.Columns[0].FieldName).asinteger;
fila:=2;
columna:=1;

while (not(Data.eof)) and (codfar = Data.FieldByName(DBGrid1.Columns[0].FieldName).asinteger) do

begin
for columna := 0 to dbgrid1.Columns.Count-1 do
begin
excel.Cells[fila,columna + 1].Value:=Data.FieldByName (DBGrid1.Columns[columna].FieldName).asString;
end;
Data.Next;
fila:= fila + 1;
end;
hoja:=hoja + 1;
fila:=2;
columna:=1;
end;

//excel.Cells[fila,1].Value:='=SUM(a1:a3)'
Sheet.Cells.Columns.AutoFit;
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 08:55:03.


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
Copyright 1996-2007 Club Delphi