Podes utilizar algo asi, espero te ubiques o extraigas lo elemental mi querido Watson
saludes...
Wait Window At 10, 70 Nowait "Espere un momento hasta que se carguen todos los registros..."
Local xalias As Cursor
xalias = Alias()
Goto Top
Public oexcel, xperido, xformato
xformato = '"##,###,###,##0.00"'
oexcel = Createobject("excel.application")
If Vartype(oexcel) <> "O"
= Messagebox( ;
"Microsoft excel no esta instalado...",0+16, "Alerta")
Return
Endif
oexcel.workbooks.Add()
oexcel.Visible = .T.
oexcel.cells(1, 2).Value = Upper(alcaldia.alcaldia)
oexcel.activesheet.usedrange.entirecolumn.AutoFit
oexcel.cells(2, 2).Value = "Presupuesto y Ejecución de Egresos por periodo Año: " + xano
oexcel.Range(oexcel.cells(1, 1), oexcel.cells(4,7)).Select
oexcel.Range(oexcel.cells(1, 1), oexcel.cells(4, 7)).Font.bold = .T.
oexcel.Range(oexcel.cells(4, 1),oexcel.cells(4,7)).Font.Name ="Arial"
oexcel.Range(oexcel.cells(4, 1),oexcel.cells(4,7)).Font.Size = 12
oexcel.cells(5, 1).Value ="Código"
oexcel.cells(5, 2).Value = "Concepto de la cuenta"
oexcel.cells(5, 3).Value = "Pre.anual"
oexcel.cells(5, 4).Value = "Pre.periodo"
oexcel.cells(5, 5).Value = "Egr.periodo"
oexcel.cells(5, 6).Value = "% Cum."
oexcel.cells(5, 7).Value = "Egr.acumulados"
oexcel.Range(oexcel.cells(5, 1),oexcel.cells(5, 7)).Select
oexcel.Range(oexcel.cells(5, 1),oexcel.cells(5,7)).Font.bold = .T.
oexcel.Range(oexcel.cells(5, 1),oexcel.cells(5,7)).Font.Name ="Arial"
oexcel.Range(oexcel.cells(5, 1), oexcel.cells(5, 7)).Font.Size = 9
oexcel.Selection.autoformat(2, .T., .T.,.T., .T., .T.,.T.)
oexcel.Rows("5:5").RowHeight = 20
oexcel.activesheet.usedrange.entirecolumn.AutoFit
oexcel.Range(oexcel.cells(5, 1), oexcel.cells(5,7)).horizontalalignment = - 4108
oexcel.Range(oexcel.cells(5, 1), oexcel.cells(5,7)).verticalalignment = -4108
Local desde, hasta As Integer
desde = 6
L = 6
Public tot1, tot2, tot3, tot4,tot5, tot6, tot7 As Number
Store 0.00 To tot3, tot4, tot5, tot7, tot9
Select &xalias
Scan
oexcel.cells(L, 1).Value = codigo
oexcel.cells(L, 2).Value = concepto
oexcel.cells(L, 3).Value = panual
oexcel.cells(L, 4).Value = pinicial
oexcel.cells(L, 5).Value = pejecutado
oexcel.cells(L, 6).Value = pc
oexcel.cells(L, 7).Value = pejecutado_a
If cabecera = 1
oexcel.cells(L,1).Font.bold = .T.
oexcel.cells(L,2).Font.bold = .T.
oexcel.cells(L,3).Font.bold = .T.
oexcel.cells(L,4).Font.bold = .T.
oexcel.cells(L,5).Font.bold = .T.
oexcel.cells(L,6).Font.bold = .T.
oexcel.cells(L,7).Font.bold = .T.
Else
tot3 = tot3 + panual
tot4 = tot4 + pinicial
tot5 = tot5 + pejecutado
tot7 = tot7 + pejecutado_a
Endif
L = L + 1
Select &xalias
Endscan
Select &xalias
If Eof()
L = L + 4
oexcel.cells(L, 2).Value = "Total gasto .............................................................C$ "
oexcel.cells(L, 3).Value = tot3
oexcel.cells(L, 4).Value = tot4
oexcel.cells(L, 5).Value = tot5
oexcel.cells(L, 7).Value = tot7
oexcel.cells(L, 2).Font.Size = 14
oexcel.cells(L, 3).Font.Size = 14
oexcel.cells(L, 4).Font.Size = 14
oexcel.cells(L, 5).Font.Size = 14
oexcel.cells(L, 7).Font.Size = 14
oexcel.cells(L, 2).Font.bold = .T.
oexcel.cells(L, 3).Font.bold = .T.
oexcel.cells(L, 4).Font.bold = .T.
oexcel.cells(L, 5).Font.bold = .T.
oexcel.cells(L, 7).Font.bold = .T.
Endif
hasta = L
oexcel.Range(oexcel.cells(5, 2), oexcel.cells(5,9)).Select
oexcel.activesheet.usedrange.entirecolumn.AutoFit
oexcel.activeworkbook.activesheet.Columns("B:B").ColumnWidth = 45
oexcel.Range(oexcel.cells(desde,1), oexcel.cells(hasta,9)).Font.Name = "Arial"
oexcel.Range(oexcel.cells(desde,1),oexcel.cells(hasta,9)).Font.Size = 8
oexcel.Range(oexcel.cells(6,3),oexcel.cells(hasta,7)).numberformat = &xformato
oexcel.activeworkbook.activesheet.pagesetup.leftheader = " "
oexcel.activeworkbook.activesheet.pagesetup.centerheader = Upper(alcaldia.alcaldia)
oexcel.activeworkbook.activesheet.pagesetup.RightHeader = "Página: &P"
oexcel.activeworkbook.activesheet.pagesetup.RightFooter = "Fecha de impresión: &D &T dsg"
oexcel.activeworkbook.activesheet.pagesetup.leftfooter = "Sistema de Presupuesto SISCO-INIFOM Central"
oexcel.activeworkbook.activesheet.pagesetup.printgridlines = .F.
oexcel.activeworkbook.activesheet.pagesetup.centerhorizontally = .T.
oexcel.activeworkbook.activesheet.pagesetup.centervertically = .F.
oexcel.activeworkbook.activesheet.pagesetup.Orientation = 1
oexcel.activeworkbook.activesheet.pagesetup.Papersize = 1
oexcel.activeworkbook.activesheet.pagesetup.printarea = "$A:$K"
oexcel.activeworkbook.activesheet.pagesetup.printtitlerows = "$1:$7"
oexcel.activeworkbook.activesheet.pagesetup.Zoom = 69
oexcel.activeworkbook.printpreview
Wait Window At 10, 70 Timeout 0.5 "listo"
Wait Clear
oexcel = .Null.
Release tot1, tot2, tot3, tot4,tot5, tot6, tot7, oexcel