FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
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; |
|
|
|