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
  #1  
Antiguo 22-09-2007
Avatar de GustavoCruz
GustavoCruz GustavoCruz is offline
Miembro
 
Registrado: jul 2006
Ubicación: Sampués Sucre (Colombia)
Posts: 296
Poder: 20
GustavoCruz Va por buen camino
Question Encuentro código en internet sobre excel... Alguien puede mejorarlo...

Prueba con esta funcion que escribio uno de los muchos gurus de delphi


Código Delphi [-]
 
procedure SendToExcel(aDataSet: TDataSet); 
var 
  PreviewToExcel: TExcelApplication; 
  RangeE: Excel2000.ExcelRange; //or RangeE: Excel97.Range 
  I, Row: Integer; 
  Bookmark: TBookmarkStr; 
begin 
  PreviewToExcel := TExcelApplication.Create(Self); 
  PreviewToExcel.Connect; 
  PreviewToExcel.Workbooks.Add(NULL, 0); 
  RangeE := PreviewToExcel.ActiveCell; 
  for I := 0 to aDataSet.Fields.Count - 1 do 
  begin 
    RangeE.Value := aDataSet.Fields[i].DisplayLabel; 
    RangeE := RangeE.Next; 
  end; 
  aDataSet.DisableControls; 
  try 
    Bookmark := aDataSet.Bookmark; 
    try 
      aDataSet.First; 
      Row := 2; 
      while not aDataSet.EOF do 
      begin 
        //Write down Record As Row in msExcel 
        RangeE := PreviewToExcel.Range['A' + IntToStr(Row), 'A' + IntToStr(Row)]; 
        for I := 0 to aDataSet.Fields.Count - 1 do 
        begin 
          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; 
end;

La cuestión es que al implementarlo demora mucho para mostrar el resultado, esto cuando el dataset es grande
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 05:16:06.


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