miara quie te pongo un pequeño ejemplo mira si lo puedes adecuar a tu necesidad..
m.oExcel = CREATEOBJECT("Excel.Application")
WITH m.oExcel
&&Abrimos un libro nuevo
.Workbooks.ADD
&&Agregamos hojas (en caso necesario)
.Sheets.ADD
&&Cambiamos el nombre de la hoja
.activesheet.NAME = "Mi Hoja"
&&Le damos formato a una celda
.Sheets("Mi Hoja").cells(1,1).NumberFormat = "#,##0.00"
&&Salvamos el libro
.SAVE
&&Salimos de Excel
.QUIT
RELEASE m.oExcel
aqui est otro..
oExcel = createObject('Excel.Application')
oWorkbooks = oExcel.Workbooks.open(pagos) aqui es donde me marca error
Son = oWorkbooks.ActiveSheet.UsedRange.Rows.Count
Son1 = oWorkbooks.ActiveSheet.UsedRange.Columns.Count
if son > 1
With oWorkbooks.ActiveSheet
&& FILA = FILAS DE EXCEL
&& COLUMNA = COLUMNAS DE EXCEL
For FILA = 2 to son
VALOR_DE_LA_CELDA = .cells(FILA,columna).value
SELE pagos
APPEND BLANK
REPLACE auto WITH auto
replace docto with docto
replace fec_venc with fec_venc
replace importe wiTH importe
Endfor
Endwith
ENDIF
mira este un programita que hice yo por ahi para una aplicacion parecida a la que tu necesitas solo que este era para una de ventas por producto por mes...
espero te sirva..
aqui te pondo un ejemplo completo de como lo puedes hecer
para que lo pruebes
http://www.gigasize.com/get.php?d=vrnbv4dlm5fIF USED('tabla')
USE IN 'tabla'
endif
Do Case
Case Thisform.optiongroup1.Value = 1
Use c:\productos_todo.Dbf Alias tabla
Case Thisform.optiongroup1.Value = 2
Use c:\productos_cantidad.Dbf Alias tabla
Case Thisform.optiongroup1.Value = 3
Use c:\productos_monto.Dbf Alias tabla
Endcase
x_registros = Afields(campos,'tabla')
x_periodo = 'Fecha inicial : 01/01/2008 Fecha final : 31/01/2008'
xlCenter = -4108
xlBottom = -4107
xlContext = -5002
xlDiagonalDown = 5
xlDiagonalUp = 6
xlEdgeLeft = 7
xlEdgeTop = 8
xlEdgeBottom = 9
xlEdgeRight = 10
xlInsideVertical = 11
xlInsideHorizontal = 12
xlNone = -4142
xlContinuous = 1
xlAutomatic = -4105
xlHairline = 1
Wait Windows 'Creado el objeto Excel....' Nowait
oexcel = Createobject('excel.application')
oexcel.Workbooks.Add
If Type('oexcel') = 'O'
x_fila = 1
x_columna = 1
Wait Windows 'Generando encabezados...' Nowait
oexcel.cells(x_fila,x_columna).Select
oexcel.Selection.Font.Size = 12
oexcel.Selection.Font.Bold = .T.
oexcel.Selection.Value = Alltrim(g_empresa)
x_fila = x_fila + 1
oexcel.cells(x_fila,x_columna).Select
oexcel.Selection.Font.Size = 10
oexcel.Selection.Font.Bold = .T.
oexcel.Selection.Value = 'REPORTE DE PRODUCTO POR SUCURSAL'
x_fila = x_fila + 2
oexcel.cells(x_fila,x_columna).Select
oexcel.Selection.Font.Size = 8
oexcel.Selection.Font.Bold = .T.
oexcel.Selection.Value = x_periodo
x_fila = x_fila + 2
oexcel.Rows(x_fila).Select
oexcel.Selection.Font.Bold = .T.
IF Thisform.optiongroup1.Value = 1
For i = 1 To x_registros
x_columna = i
If x_columna = 1
oexcel.cells(x_fila,x_columna).Select
oexcel.Selection.ColumnWidth = 30
oexcel.cells(x_fila,x_columna).Value = campos(i,1)
Endif
If Mod(i,2) = 0 &&Or i = x_registros
oexcel.Columns(i).Select
oexcel.Selection.NumberFormat = "#,##0"
oexcel.Selection.ColumnWidth = 5.5
oexcel.Columns(i+1).Select
oexcel.Selection.NumberFormat = "#,##0.00"
oexcel.Selection.ColumnWidth = 7.5
If Substr(campos(i,1),Len(campos(i,1))-1,1) = '_'
oexcel.cells(x_fila,x_columna).Value = Substr(campos(i,1),1,Len(campos(i,1))-2)
Else
oexcel.cells(x_fila,x_columna).Value = campos(i,1)
Endif
oexcel.Range(oexcel.cells(x_fila,x_columna),oexcel.cells(x_fila,x_columna+1)).Select
With oexcel.Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = .F.
.Orientation = 0
.AddIndent = .F.
.IndentLevel = 0
.ShrinkToFit = .F.
.ReadingOrder = xlContext
.MergeCells = .F.
Endwith
oexcel.Selection.Merge
If i = x_registros-1
oexcel.cells(x_fila,x_columna).Value = 'TOTAL'
Endif
Endif
Next
x_fila = x_fila + 1
For i = 2 To x_registros
x_columna = i
If Mod(i,2) = 0
oexcel.cells(x_fila,x_columna).Value = 'CANT'
Else
oexcel.cells(x_fila,x_columna).Value = 'MONTO'
Endif
Next
oexcel.Range(oexcel.Columns(1),oexcel.Columns(x_registros)).Select
ELSE
For i = 1 To x_registros
x_columna = i
If x_columna = 1
oexcel.cells(x_fila,x_columna).Select
oexcel.Selection.ColumnWidth = 30
oexcel.cells(x_fila,x_columna).Value = campos(i,1)
Else
IF thisform.optiongroup1.Value = 2
oexcel.Columns(i).Select
oexcel.Selection.NumberFormat = "#,##0"
ELSE
oexcel.Columns(i).Select
oexcel.Selection.NumberFormat = "#,##0.00"
endif
oexcel.Selection.ColumnWidth = 8
If Substr(campos(i,1),Len(campos(i,1))-1,1) = '_'
oexcel.cells(x_fila,x_columna).Value = Substr(campos(i,1),1,Len(campos(i,1))-2)
Else
oexcel.cells(x_fila,x_columna).Value = campos(i,1)
Endif
If i = x_registros
oexcel.cells(x_fila,x_columna).Value = 'TOTAL'
Endif
Endif
Next
ENDIF
oexcel.Rows(x_fila).Select
oexcel.Selection.Font.Bold = .T.
With oexcel.Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = .F.
.Orientation = 0
.AddIndent = .F.
.IndentLevel = 0
.ShrinkToFit = .F.
.ReadingOrder = xlContext
.MergeCells = .F.
Endwith
Select tabla
Go Top
Scan
x_columna = 0
x_fila = x_fila + 1
Wait Windows 'Enviando a excel el producto ----> ' + Alltrim(producto) Nowait
For i = 1 To x_registros
x_columna = x_columna + 1
x_valor = 'tabla.' + campos(i,1)
x_tipo = campos(i,2)
If x_tipo = 'N'
oexcel.cells(x_fila,x_columna).Value = &x_valor
Else
oexcel.cells(x_fila,x_columna).Value = [']+&x_valor
Endif
Next
Endscan
oexcel.Rows(x_fila).Select
oexcel.Selection.Font.Bold = .T.
oexcel.Range(oexcel.cells(6,1),oexcel.cells(x_fila,x_columna)).Select
oexcel.Selection.BorderS(xlDiagonalDown).LineStyle = xlNone
oexcel.Selection.BorderS(xlDiagonalUp).LineStyle = xlNone
With oexcel.Selection.BorderS(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlHairline
Endwith
With oexcel.Selection.BorderS(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlHairline
Endwith
With oexcel.Selection.BorderS(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlHairline
Endwith
With oexcel.Selection.BorderS(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlHairline
Endwith
With oexcel.Selection.BorderS(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlHairline
Endwith
With oexcel.Selection.BorderS(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlHairline
Endwith
oexcel.Selection.Font.Size = 8
oexcel.Visible = .T.
Release oexcel
Messagebox('Proceso concluido')
Else
Endif