Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 30-07-2008
[FGarcia] FGarcia is offline
Miembro Premium
 
Registrado: sep 2005
Ubicación: Cordoba, Veracruz, México
Posts: 1.123
Poder: 22
FGarcia Va por buen camino
¡50,000 registros es necesariamente tedioso!

Ahora bien, ¿realmente necesitas enviar a excel esa cantidad de registros? y ademas -supongo- estas con ¿excel visible?

No se, nunca he manejado esa cantidad de registros a excel, lo mas que he enviado han sido 400 a 500 con 6 columas por registro y si con excel visible en una maquina de 256 MB en RAM, 10 segundos a lo mas de tiempo empleado (excel, aplicacion, servicios de windows, msn y player todo junto)

Tal vez tengas que reconsiderar algo de tu procedimiento.

No dejes de contarnos como lo solucionas.
Responder Con Cita
  #2  
Antiguo 06-08-2008
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Poder: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Exportar a Excel usando OLE es excesivamente lento para esa cantidad de registros. Obtendrás una mejora considerable si usas ADO.

No he visto el componente que indica nuestro amigo tcp_ip_es, dale un aprueba a ver qué tal. De todas formas te comento que puedes exportar datos (sin formato) a Excel usando los componentes ExportSuite de nuestro compañero Federico Firenze, mismos que podrás encontrar en su página. Tienen la ventaja de exportar directamente al formato BIFF sin necesidad de tener Excel instalado, lo cual los hace sumamente rápidos.

// Saludos
Responder Con Cita
  #3  
Antiguo 06-08-2008
Avatar de Gaim2205
Gaim2205 Gaim2205 is offline
Miembro
 
Registrado: ago 2007
Ubicación: Durango, Mexico
Posts: 144
Poder: 20
Gaim2205 Va por buen camino
Código Delphi [-]
function TForm1.GetLetraRango(NumCampos: Integer): String;
const
elementos = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
begin
if NumCampos < 27 then
Result:= elementos[NumCampos]
else
begin
Result:=elementos[(NumCampos - 1) div 26];
Result:=Result + elementos[((NumCampos - 1) mod 26)+1];
end;
end;

Código Delphi [-]
procedure TForm1.SendToExcel(Grid: TDBGrid; Forma: TForm);
var
bm: TBookmark;
col, row, renExcel: Integer;
sline, LetraRango, rango: String;
mem: TMemo;
ExcelApp: Variant;
Format : OleVariant;
Evento:TDataSetNotifyEvent;
ToExcel:Boolean;
begin
ToExcel := true;
Screen.Cursor := crHourglass;
Grid.DataSource.DataSet.DisableControls;
bm := Grid.DataSource.DataSet.GetBookmark;
Grid.DataSource.DataSet.First;
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.WorkBooks.Add($FFFFEFB9);
ExcelApp.WorkBooks[1].WorkSheets[1].Name := 'Sheet1';
Grid.DataSource.DataSet.First;
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range['A2:B2'].Select;
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range['A2:B2'].Font.FontStyle := 'Bold';
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range['A2:B2'].Font.Color := clNavy;
mem := TMemo.Create(Self);
mem.Visible := false;
mem.Parent := Forma;
mem.WordWrap := false;
mem.Clear;
sline := '';
for col := 0 to Grid.FieldCount-1 do
sline := sline + Grid.Fields[col].DisplayLabel + #9;
mem.Lines.Add(sline);
if toExcel then
begin
LetraRango := GetLetraRango(Grid.FieldCount);
mem.SelectAll;
mem.CopyToClipBoard;
rango := 'A3:' + LetraRango + '3';
renExcel := 3;
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range[rango].Select;
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range[rango].Font.FontStyle := 'Bold';
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range[rango].Font.Color := clBlack;
ExcelApp.Workbooks[1].WorkSheets['Sheet1'].Paste;
mem.Lines.Clear;
end;
if assigned(Grid.DataSource.DataSet.AfterScroll) then
begin
Evento:=Grid.DataSource.DataSet.AfterScroll;
Grid.DataSource.DataSet.AfterScroll:=nil;
end;
Grid.DataSource.DataSet.DisableControls;
for row := 0 to Grid.DataSource.DataSet.RecordCount-1 do
begin
sline := '';
for col := 0 to Grid.FieldCount-1 do
sline := sline + Grid.Fields[col].AsString + #9;

mem.Lines.Add(sline);
Grid.DataSource.DataSet.Next;

if toExcel then
if mem.Lines.Count = 100 then
begin
mem.SelectAll;
mem.CopyToClipBoard;
rango := 'A' + IntToStr(renExcel+1) + ':' + LetraRango + IntToStr(renExcel+1+mem.Lines.Count-1);
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range[rango].Select;
Format := '@';
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range[rango].NumberFormat := Format;
ExcelApp.Workbooks[1].WorkSheets['Sheet1'].Paste;
renExcel := renExcel + mem.Lines.Count;
mem.Lines.Clear;
end;
end;
if mem.Lines.Count > 0 then
begin
mem.SelectAll;
mem.CopyToClipboard;
if toExcel then
begin
rango := 'A' + IntToStr(renExcel+1) + ':' + LetraRango + IntToStr(renExcel+1+mem.Lines.Count-1);
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range[rango].Select;
Format := '@';
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range[rango].NumberFormat := Format;
ExcelApp.Workbooks[1].WorkSheets['Sheet1'].Paste;
ExcelApp.WorkBooks[1].WorkSheets['Sheet1'].Range['A3:A3'].Select;
ExcelApp.Visible := true;
end;
end;

Grid.DataSource.DataSet.AfterScroll:=Evento;
Grid.DataSource.DataSet.EnableControls;

mem.Free;
Grid.DataSource.DataSet.GotoBookmark(bm);
Grid.DataSource.DataSet.FreeBookmark(bm);
Grid.DataSource.DataSet.EnableControls;
Screen.Cursor := crDefault;
end;

Código Delphi [-]
SendToExcel(DBGrid1,Form1);

Y necesitas un componente ExcelApplication de la pestaña servers (delphi 7).

Última edición por Gaim2205 fecha: 06-08-2008 a las 18:28:52.
Responder Con Cita
  #4  
Antiguo 08-08-2008
Avatar de Faust
Faust Faust is offline
Miembro
 
Registrado: abr 2006
Ubicación: México D.F.
Posts: 930
Poder: 21
Faust Va por buen camino
Has pensado cuantas filas devuelve tu consulta...

Porque Excel 2003 maneja máximo 65 mil y tantas filas, no he probado la exportación a Excel 2007, porque esta versión soporta muchísimas filas más.

Saludos
__________________
Herr Heins Faust
Responder Con Cita
Respuesta


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
Exportar a excel raf.rsr Servers 42 08-05-2012 20:35:16
Exportar a Excel jocey Varios 3 06-11-2007 16:15:23
Exportar a excel... BuenaOnda Varios 3 20-08-2007 08:55:07
Exportar a Excel erasmorc OOP 4 04-08-2006 15:03:50
Exportar .gdb a Excel Novata2006 Firebird e Interbase 0 16-05-2006 10:52:08


La franja horaria es GMT +2. Ahora son las 17:55:34.


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