RE:formato de impresion a hoja de excel
Lo siento, tu mail no existe tendras otro?,
anexo parte del codigo q utiliza macros de excel
***INICIO*******
SELECT tabla
LOCAL cErrores, lExcel,vlLinea,vlGrupo,oExcel,vlTipoBono
Release oExcel
* BUSCO UNA SESION DE EXCEL YA ACTIVA:
cErrores = ON("ERROR")
ON ERROR lExcel = .F.
oExcel = GetObject(,"excel.application")
ON ERROR &cErrores
IF !TYPE('oExcel')="O" && * NO ESTABA ACTIVA. PREPARO UNA NUEVA SESION DE EXCEL:
oExcel = CREATEOBJECT("Excel.Application")
ELSE
* Si existe el archivo y se esta utilizando lo cierro
FOR EACH x IN oExcel.Workbooks
NameFileTMP = x.Name
IF NameFileTMP = "Automation.XLS"
x.CLOSE
ENDIF
ENDFOR
ENDIF
oExcel.VISIBLE = .t. && VISUALIZO EXCEL
oExcel.Workbooks.ADD && PREPARO UN NUEVO TRABAJO DE EXCEL
oExcel.sheets.Add
*oExcel.sheets.Add &&Si queremos agregar más hojas
*oExcel.sheets.Add
*-
vrNumHojas = oExcel.sheets.count() &&Cantidad de hojas en el libro
IF vrNumHojas > 1
oExcel.sheets(1).select
ELSE
oWorksheet1 = oExcel.Worksheets[1]
oExcel.Worksheets.Add(,oWorksheet1,1,)
ENDIF
vrNumHojas = oExcel.sheets.count()
IF vrNumHojas = 1
oWorksheet1 = oExcel.Worksheets[2]
oExcel.Worksheets.Add(,oWorksheet1,1,)
ENDIF
vrNuPag = 1
***************
oExcel.sheets(vrNuPag).select &&Seleccionamos la hoja 1
oExcel.ActiveSheet.name = "Automation con Excel" &&Ponemos título a la hoja
***************
vrRows = 4
WITH oExcel
.Cells(vrRows,1) = [Compañía]
.Cells(vrRows,2) = [Contacto]
.Cells(vrRows,3) = [Título]
.Cells(vrRows,4) = [Dirección]
.Range([A4:D4]).Select
.Range([A4:D4]).Font.Name = [Arial]
.Range([A4:D4]).Font.Size = 8
.Range([A4:D4]).Font.Bold = .T.
.RANGE([A4:D4]).Borders(1).weight=2 && Izquierdo
.RANGE([A4:D4]).Borders(2).weight=2 && Derecho
.RANGE([A4:D4]).Borders(3).weight=2 && Arriba
.RANGE([A4:D4]).Borders(4).weight=2 && Abajo
.Range([A4:D4]).Interior.Color = RGB(220,220,220) && RGB(192,192,192) && Light Gray
SELECT tabla
GO Top
DO While !Eof()
vrRows = vrRows + 1
.Cells(vrRows,1) = ['] + Company
.Cells(vrRows,2) = ['] + Contact
.Cells(vrRows,3) = Title
.Cells(vrRows,4) = Address
Skip
ENDDO
.Cells.Select
.Cells.EntireColumn.AutoFit
.ActiveWindow.SmallScroll(-21)
.Range("A5").Select
.Range(.Selection, .Selection.End(-4161)).Select
.Range(.Selection, .Selection.End(-4121)).Select
.Selection.Borders(5).LineStyle = -4142
.Selection.Borders(6).LineStyle = -4142
With .Selection.Borders(7)
.LineStyle = 1
.Weight = -4138
.ColorIndex = -4105
EndWith
With .Selection.Borders(8)
.LineStyle = 1
.Weight = -4138
.ColorIndex = -4105
EndWith
With .Selection.Borders(9)
.LineStyle = 1
.Weight = -4138
.ColorIndex = -4105
EndWith
With .Selection.Borders(10)
.LineStyle = 1
.Weight = -4138
.ColorIndex = -4105
EndWith
With .Selection.Borders(11)
.LineStyle = 1
.Weight = 1
.ColorIndex = -4105
EndWith
With .Selection.Borders(12)
.LineStyle = 1
.Weight = 1
.ColorIndex = -4105
EndWith
.ActiveWindow.View = 2
.ActiveSheet.VPageBreaks(1).DragOff(-4161,1)
.ActiveWindow.View = 1
.ActiveWindow.SelectedSheets.PrintPreview
ENDWITH
oExcel.VISIBLE = .t. && VISUALIZO EXCEL
Release oExcel