I have been looking to the example of Ole HMG and some other examples that I found on the Web, about sending a report to an Excel file, but frankly I do not understand how to do it annexed the sample code that would normally use for Clipper generate the report, the concerns I have is about how you can modify this code Clipper, for example with the code to pass it on to Excel (Objeto:Cells, Objeto:Cells:Font:Name, Objeto:Cells:Font:Size, etc.)
To send the report to Excel how to manage the page break that I use in Clipper (as you can see in the code) or it should not be used, in order.
Some of you could help me please with the item and give me some example or idea how to do what I need.
Thank you very much
Greetings
Javier
Español
He estado revisando el ejemplo de Ole de HMG y algunos otros ejemplos que he encontrado en la Web, acerca de enviar un reporte a un archivo de Excel, pero sinceramente no logro entender como hacerlo, anexo el ejemplo de código que normalmente uso en Clipper para generar el reporte, las dudas que tengo es acerca de como puedo modificar este código de Clipper, por ejemplo con el código para pasarlo a Excel (Objeto:Cells, Objeto:Cells:Font:Name, Objeto:Cells:Font:Size, etc.)
Para enviar el reporte a Excel como se maneja el salto de página que utilizo en Clipper (como pueden ver en el código) o esto no se debería utilizar, en fin.
Alguno de ustedes me pudiera ayudar por favor con el tema y darme algún ejemplo o idea de como hacer lo que necesito.
Muchas Gracias
Saludos
Javier
P.S. Sorry for the extensive post
Code: Select all
Sele Facturas
DbSetRelation( "Clientes", { || Facturas->f_num_cte }, "Facturas->f_num_cte" )
// Si el reporte es en forma global
If _Tipo==1
Set Order To 5
bWhile :={ || f_fech_fac <= g_fech_fin .and. !EOF() }
DbSeek( DTOS(g_fech_ini), .T. )
bFiltro := { || .T. }
// Si el reporte es de un almacén
ElseIf _Tipo==2
Set Order To 3
bWhile :={ || f_cve_alm==g_cve_alm .and. f_fech_fac <= g_fech_fin .and. !EOF() }
DbSeek( g_cve_alm + DTOS(g_fech_ini), .T. )
bFiltro := { || .T. }
EndIf
Hoja := _GTotal := _GTIva := 0
Do While Eval( bWhile )
ChecarSaltoHoja( )
If NextKey() = K_ESC
Exit
Endif
If Eval( bFiltro )
@PRow()+1, 1 Say g_num_fact := f_num_fact
@PRow() , 16 Say FechaLegible(f_fech_fac)
@PRow() , 27 Say f_num_cte +'-'+ Left(Clientes->f_nomb_cte, 30)
@PRow() , 65 Say f_cve_alm
@PRow() , 79 Say Iif(f_tipo_pag==CONTADO, 'Contado', 'Cr‚dito')
@PRow() , 89 Say f_plazo
@PRow() , 95 Say Trans(f_total, '$9,999,999.99')
@PRow() ,111 Say Trans(f_desc_grl, '99.9') + '%'
@PRow() ,119 Say Iif(f_pagada, 'Si', 'No')
If f_cancel
@PRow() ,123 Say 'Cancelada'
Else
@PRow() ,123 Say Iif(f_afectada, 'Afectada', 'Pendiente' )
EndI
Sele ArtFacturas
DbSetRelation( "Articulos", { || ArtFacturas->f_cve_art }, "ArtFacturas->f_cve_art" )
g_suma := 0
@PRow()+1, 0 Say ''
ChecarSaltoHoja( )
@Prow()+1, 0 Say ' Descripción Cantidad Unidad Precio Total Descto% IVA'
DbSeek( g_num_fact )
Do While f_num_fact == g_num_fact .and. !EOF()
g_cantidad := f_cantidad
g_precio := f_precio
g_total := Round( g_cantidad * g_precio * (1-f_descto/100), 2)
g_suma += g_total
If _Global==2 // si se deben imprimir los artículos
ChecarSaltoHoja( )
If CVE_COMENT $ f_cve_art
@PRow()+1, 29 Say BusqComentFact( g_num_fact, nComentar++, 1 )
Else
@PRow()+1, 23 Say f_cve_art + '-' + Left(Articulos->f_nomb_art,45)
Endif
@PRow() , 76 Say Trans( g_cantidad, '999,999.999')
@PRow() , 90 Say Articulos->f_u_venta
@PRow() , 96 Say Trans( g_precio, '$999,999.99' )
@PRow() ,109 Say Trans( g_total, '$999,999.99' )
@PRow() ,122 Say Trans(f_descto, '999.999')+ '%'
@PRow() ,130 Say Iif(f_con_iva, 'Si', 'No' )
Endif
DbSkip()
EndDo
If _Global==2 // si se deben imprimir los artículos
@PRow()+1,109 Say '-------------'
@PRow()+1, 99 Say 'SubTotal: '
@PRow() ,109 Say Trans(g_suma, '$999,999.99')
@PRow()+1, 0 Say ''
Endif
Sele Facturas
If ! f_cancel
_GTotal += g_suma
_GTIva += ( f_total - g_suma )
Endif
Endif
DbSkip()
EndDo
If _GTotal > 0
@PRow()+1, 0 Say PadL( 'SubTotal: '+ Trans(_GTotal, '$9999,999.99')+' IVA: '+ Trans(_GTIva, '$9999,999.99'),132)
Endif
DbClearRelation()
/*****
* Para checar si hay que iniciar una nueva hoja
*****/
Static Procedure ChecarSaltoHoja( )
Local LinXHoja:=58
If PRow()==0 .or. PRow() > LinXHoja
If PRow() > LinXHoja
_Eject( )
Endif
TipoLetra( g_off_cond )
CentraEnImpresora( Trim(g_empresa), 'cen', PRow(), 80 )
@PRow()+ 1, 0 Say FechaLegible( Date() )
CentraEnImpresora( g_sistema, 'cen', PRow(), 80 )
@PRow() ,73 Say 'Hoja:' + Str( ++Hoja, 2)
TipoLetra( g_on_bold )
CentraEnImpresora( 'Facturas de '+ FechaLegible(g_fech_ini) +' y el '+ FechaLegible(g_fech_fin) , 'cen', PRow()+1, 80 )
If _Tipo==3 .or. _Tipo==4
CentraEnImpresora( AllTrim('del Cliente '+g_num_cte+'-'+Clientes->f_nomb_cte), 'cen', PRow()+1, 80 )
EndI
TipoLetra( g_off_bold )
TipoLetra( g_on_cond )
@Prow()+1, 0 Say Replicate( '-', 132 )
@Prow()+1, 0 Say ' Factura Fecha C l i e n t e Almacén Pago Plazo Total Descto% Status'
@Prow()+1, 0 Say Replicate( '-', 132 )
Endif
Return
/******/
/****
* Procedimiento para hacer un Eject
****/
Procedure _Eject( )
If __Device == IMPRESORA .or. __Device == ARCHIVOTXT
Eject
Else // a pantalla
@Prow()+3, 0 Say ""
SetPrc(0,0)
Endif
Return
/********/