Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Servers
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #5  
Antiguo 23-09-2007
pcicom pcicom is offline
Miembro
 
Registrado: may 2003
Ubicación: MONTERREY MEXICO
Posts: 253
Poder: 24
pcicom Va por buen camino
Cita:
Empezado por GustavoCruz Ver Mensaje
Prueba con esta funcion que escribio uno de los muchos gurus de delphi


Código Delphi [-]
 
procedure SendToExcel(aDataSet: TDataSet); 
var
  xFile:TextFile;
  cFile:String; 
  I, Row: Integer; 
begin 
  cFile := 'reporte.xls';
  AssignFile(xFile,cFile);
  writeln(xFile,'');
  writeln(xFile,'');

  for I := 0 to aDataSet.Fields.Count - 1 dobegin 
         
    RangeE.Value := aDataSet.Fields[i].DisplayLabel; 
    RangeE := RangeE.Next; 
  end;
  writeln(xFile,'');
 
  aDataSet.DisableControls; 
  try 
    Bookmark := aDataSet.Bookmark; 
    try 
      aDataSet.First; 
      Row := 2; 
      whilenot aDataSet.EOF dobegin//Write down Record As Row in msExcel 
        RangeE := PreviewToExcel.Range['A' + IntToStr(Row), 'A' + IntToStr(Row)]; 
        for I := 0 to aDataSet.Fields.Count - 1 dobegin 
          RangeE.Value := aDataSet.Fields[i].AsString; 
          RangeE := RangeE.Next; 
        end; 
        aDataSet.Next; 
        Inc(Row); 
      end; 
    finally 
      aDataSet.Bookmark := Bookmark; 
    end; 
  finally 
    aDataSet.EnableControls; 
  end; 
  RangeE := PreviewToExcel.Range['A1', chr(64 + aDataSet.Fields.Count) + 
IntToStr(Row - 1)]; 
  RangeE.AutoFormat(8, NULL, NULL, NULL, NULL, NULL, NULL); 
  PreviewToExcel.Visible[0] := True; 
  PreviewToExcel.Disconnect; 

  writeln(xFile,'
'
); close(xFile); end;

La cuestión es que al implementarlo demora mucho para mostrar el resultado, esto cuando el dataset es grande


OTRA FORMA es que CREES el XLS al vuelo como un archivo tipo HTML con extencin de EXCEL .xls, y despues lo abres..
__________________
Poco ha de saber el que no pregunta.. Yo por eso soy un pregunton
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Alguien puede recomedar algun componente VCL para código de Barras ??? QuarkBcn Impresión 5 29-04-2007 14:07:55
Donde encuentro el codigo de CAERQUES dtomeysoto Conexión con bases de datos 6 19-05-2006 22:28:58
Ehm, alguien me puede facilitar éste código? gatsu PHP 3 09-07-2004 13:35:01
donde encuentro manuales de Kylix con codigo gaoss Lazarus, FreePascal, Kylix, etc. 0 25-03-2004 20:25:30
alguien sabe donde encuentro quickreport en delphi 7 pzala Impresión 2 30-11-2003 19:22:40


La franja horaria es GMT +2. Ahora son las 10:32:31.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi