Ver Mensaje Individual
  #2  
Antiguo 17-09-2005
lgarcia lgarcia is offline
Miembro
 
Registrado: jul 2004
Posts: 479
Reputación: 20
lgarcia Va por buen camino
Problema con Excel

Hola:

Yo trabajo con Office 2003 y nunca he tenido ese problema te voy a enviar un codigo a ver si te sirve

Código:
  
procedure TFormMenu.Plantilla1Click(Sender: TObject);
var
  Excel, Libro: Variant;
  i: integer;
  Nombre: string;
begin
  Excel:=CreateOleObject('Excel.Application');
  Excel.Visible := False;
  Excel.DisplayAlerts:= False;
  Excel.WorkBooks.Add('C:\Archivos de programa\Tienda\Productos.xlt');
  Excel.WorkBooks[1].WorkSheets[1].Name := 'Productos';
  Libro := Excel.WorkBooks[1].WorkSheets['Productos'];
  with Productos do
  begin
	Close;
	Open;
  end;
  Productos.First;
  i:= 2;
  while not (Productos.Eof) do
  begin
	Libro.Cells [i,1] := ProductosCodTrasval.Value;
	Libro.Cells [i,2] := ProductosDescripcionPLU.Value;
	Libro.Cells [i,3] := ProductosPrecioCosto.Value;
	Libro.Cells [i,4] := ProductosPrecioventa.Value;
	Libro.Cells [i,5] := Productosum.Value;
	Libro.Cells [i,6] := ProductosCategoria.Value;
	inc(i);
	Productos.Next;
  end;
  Libro.SaveAs('C:\Archivos de programa\Tienda\Listado transferencias');
  ShowMessage(' El fichero Listado transferencias.xls ha sido creado exitosamente');
  Excel.Quit;
end;
En el uses de la Unit incluyo Excel97, ComObj y siempre me trabaja bien en este caso yo utilizo una plantilla Excel (.xlt) para darle formato a las celdas y no tener que preocuparme por la programacion.

Saludos
Luis Garcia

_____________________________
La mejor manera de decir es hacer
Responder Con Cita