Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 05-11-2012
edgar_prospero edgar_prospero is offline
Miembro
NULL
 
Registrado: mar 2012
Posts: 202
Poder: 13
edgar_prospero Va por buen camino
tamaño de hoja al exportar datos a excel

que hay amigos aqui estoy con un problema, estoy mandando un reporte a excel pero quisiera saber su hay la forma de que la hoja quede configurada a la hora de mandar la informacion, me refiero a que ya que tengo la informacion en excel y si le doy en vista previa ya este a a cierto porcentaje el tamaño de la pagina y no haya necesidad de configurarlo manualmente, no se si me explique un poco acontinuacion pongo el codigo que utilizo para mandar el reporte a excel:

Código Delphi [-]
procedure TForm5.BitBtn6Click(Sender: TObject);
var Excel : Variant;
var Libro : Variant;
var i:integer;
var j:integer;
var _FilaIni: integer;

begin

Excel := CreateOleObject ('Excel.Application');

Excel.Visible := True;


Excel.WorkBooks.Add (-4167);

Excel.WorkBooks[1].WorkSheets[1].Name := 'Reporte';

Libro := Excel.WorkBooks[1].WorkSheets['Reporte'];
excel.worksheets[1].Range['B1','B1'].ColumnWidth :=45;
excel.worksheets[1].Range['C1','C1'].ColumnWidth :=13;
excel.worksheets[1].Range['D1','E1'].ColumnWidth :=15;
excel.worksheets[1].Range['F1','F1'].ColumnWidth :=16;
excel.worksheets[1].Range['G1','H1'].ColumnWidth :=9;
excel.worksheets[1].Range['I1','I1'].ColumnWidth :=14;
Libro.Cells.Item[1,1].Font.Bold:=True;
Libro.Cells.Item[1,1].font.size:=16;

Libro.Cells.Item[1,3]:='Fecha Inventario:  '+ FormatDateTime('dd/mm/yyyy',form5.fecha.Date);
Libro.Cells.Item[1,6]:=' Supervisor:  ' +form5.supervisor.Text;
Libro.Cells.Item[2,1]:= ' Inventario en proceso del departamento: '+form5.dep2.Text + '  A  ' +form5.dep3.Text+ '  del  '  + FormatDateTime('dd/mm/yyyy',form5.inifec.Date)+ '  al  '  + FormatDateTime('dd/mm/yyyy',form5.finfec.Date);
Libro.Cells.Item[2,1].Font.Bold:=True;


Libro.Cells.Item[1,3].Font.Bold:=True;
Libro.Cells.Item[1,6].Font.Bold:=True;
Libro.Cells.Item[3,1].Font.Bold:=True;
Libro.Cells.Item[3,2].Font.Bold:=True;
Libro.Cells.Item[3,3].Font.Bold:=True;
Libro.Cells.Item[3,4].Font.Bold:=True;
Libro.Cells.Item[3,5].Font.Bold:=True;
Libro.Cells.Item[3,6].Font.Bold:=True;
Libro.Cells.Item[3,7].Font.Bold:=True;
Libro.Cells.Item[3,8].Font.Bold:=True;
Libro.Cells.Item[3,9].Font.Bold:=True;



Query.Open;
i:=3;

query.SQL.Clear;
query.SQL.Add('SELECT * FROM arm0062 WHERE departamento>=:inidep and departamento<=:findep and tipo_material>=:inimat and tipo_material<=:finmat and fecha>=:inifec and fecha<=:finfec order by  codigo asc ');
query.ParamByName('inidep').Asstring:=inidep.Text;
query.ParamByName('findep').Asstring:=findep.Text;
query.ParamByName('inimat').Asstring:=inimat.Text;
query.ParamByName('finmat').Asstring:=finmat.Text;
query.ParamByName('inifec').AsDate:=inifec.Date;
query.ParamByName('finfec').AsDate:=finfec.Date;
query.Open;

while not Query.EOF do
begin

Libro.Cells [1,1] := ' CLASIC AND BASIC SA DE CV';
Libro.Cells.Item[1,1].HorizontalAlignment := xlHAlignleft;
Libro.Cells [3,1] := 'codigo';
Libro.Cells [3,2] := 'Nombre';
Libro.Cells [3,3] := 'Departamento';
Libro.Cells [3,4] := 'Tipo de Material';
Libro.Cells [3,5] := 'Cantidad piezas';
Libro.Cells [3,6] := 'Cantidad Material';
Libro.Cells [3,7] := 'Unidad';
Libro.Cells [3,8] := 'Costo';
Libro.Cells [3,9] := 'Total';

   i :=i+1;


Libro.Cells [i,1] := Query.FieldByName ('codigo').AsString;
Libro.Cells [i,2] := Query.FieldByName ('nombre').AsString;
Libro.Cells [i,3] := Query.FieldByName ('departamento').AsString;
Libro.Cells [i,4] := Query.FieldByName ('tipo_material').AsString;
Libro.Cells [i,5] := Query.FieldByName ('cant_piezas').AsString;
Libro.Cells [i,6] := Query.FieldByName ('cant_material').AsString;
Libro.Cells [i,7] := Query.FieldByName ('unidad').AsString;
Libro.Cells [i,8] := Query.FieldByName ('costo').AsString;
Libro.Cells [i,9] := Query.FieldByName ('total').AsString;


Query.Next;

end;

Query.Close;


Libro.Cells.Item[i+1,2].Font.Bold:=True;
Libro.Cells.Item[i+1,9].Font.Bold:=True;

Libro.Cells.Item[i+1,2].HorizontalAlignment := xlHAligncenter;


Libro.Cells [i+1,2] := 'TOTAL';

libro.cells[i+1,9].formula:= format( '=SUM(I4:I%d)', [i] );


DEP2.Text:='PRODUCTO TERMINADO';
DEP3.Text:='ALMACEN TEMPORAL';
inifec.Date:=date;
finfec.Date:=date;
iniFEC.SetFocus;
SUPERVISOR.Clear;
fecha.Date:=date;

end;
__________________
saludos!!!
Responder Con Cita
  #2  
Antiguo 05-11-2012
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
edgar_prospero,

Revisa este link : http://www.swissdelphicenter.ch/torr...ode.php?id=156
Código Delphi [-]
  // Este es un fragmento de código del link anterior relacionado al Page Setup
  { Page Setup }

  ExcelApp.ActiveSheet.PageSetup.Orientation := xlLandscape;

  // Left, Right Margin (Seitenränder)
  ExcelApp.ActiveSheet.PageSetup.LeftMargin  := 35;
  ExcelApp.ActiveSheet.PageSetup.RightMargin := -15;

  // Set Footer Margin
  ExcelApp.ActiveSheet.PageSetup.FooterMargin := ExcelApp.InchesToPoints(0);

  // Fit to X page(s) wide by Y tall
  ExcelApp.ActiveSheet.PageSetup.FitToPagesWide := 1;  // Y
  ExcelApp.ActiveSheet.PageSetup.FitToPagesTall := 3; // Y

  // Zoom
  ExcelApp.ActiveSheet.PageSetup.Zoom := 95;

  // Set Paper Size:
  ExcelApp.PageSetup.PaperSize := xlPaperA4;

  // Show/Hide Gridlines:
  ExcelApp.ActiveWindow.DisplayGridlines := False;

  // Set Black & White
  ExcelApp.ActiveSheet.PageSetup.BlackAndWhite := False;

  // footers
  ExcelApp.ActiveSheet.PageSetup.RightFooter := 'Right Footer / Rechte Fußzeile';
  ExcelApp.ActiveSheet.PageSetup.LeftFooter  := 'Left Footer / Linke Fußzeile';

  // Show Excel Version:
  ShowMessage(Format('Excel Version %s: ', [ExcelApp.Version]));

  // Show Excel:
  ExcelApp.Visible := True;

  // Save the Workbook
  ExcelApp.SaveAs('c:\filename.xls');

  // Save the active Workbook:
  ExcelApp.ActiveWorkBook.SaveAs('c:\filename.xls');
Nota : El método PageSetup no es soportado en Automation OLE de Excel 2010 según pude constatar al probar el código.

Espero sea útil

Nelson.
Responder Con Cita
  #3  
Antiguo 05-11-2012
edgar_prospero edgar_prospero is offline
Miembro
NULL
 
Registrado: mar 2012
Posts: 202
Poder: 13
edgar_prospero Va por buen camino
excelente respuesta gracias a esto pude solucionar mi problema con la siguiente linea

Código Delphi [-]
 Excel.ActiveSheet.PageSetup.Zoom := 65;
__________________
saludos!!!
Responder Con Cita
Respuesta



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
Cómo insertar datos en la segunda hoja de excel Viky Servers 4 19-05-2011 20:02:38
Importar datos de hoja de calculo excel a firebird 1.5 day_eli Conexión con bases de datos 1 07-02-2007 20:02:28
Como pasar datos de una hoja de Excel a Bases de Datos de Paradox Goyo OOP 1 06-02-2007 01:57:20
Exportar a excel con mas de 1 hoja Perio Varios 6 25-01-2006 17:03:48
Exportar datos de una hoja en excel a una tabla paradox vick Conexión con bases de datos 3 29-11-2005 20:22:47


La franja horaria es GMT +2. Ahora son las 19:48:27.


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