//----------------------------------------------------------------------------//
Function XlsFacturas()
Local nFormat1
Local nFormat2
Local oFileXLS
Local nFont1
Local nFont2
Local nFont3
Local nFont4
Local nFont5
Local nFor
Local i
Local nImporte := 0
Local nAbonado := 0
Local nSaldo := 0
Local cFile := Hb_CurDrive() + ':' + CurDir() + '\excel\listado_facturas.xls'
Local oRec := oClone( oRs )
Memvar o
If( !IsDirectory( hb_CurDrive() + ':\' + Curdir() + '\excel' ) )
MakeDir( hb_CurDrive() + ':\' + Curdir() + '\excel' )
End
If( File( cFile ) )
Ferase( cFile )
End
o : nRowXls := 1
Define Xls Format nFormat2 Picture '#,##0.00' // para euros
Define Xls Font nFont1 Name "Staccato222 BT" Height 10 Bold
Define Xls Font nFont2 Name "Arial" Height 8 Bold
Define Xls Font nFont3 Name "Arial" Height 8
Define Xls Font nFont4 Name "Arial" Height 12 //Bold
Define Xls Font nFont5 Name "Staccato222 BT" Height 8 Bold
Xls oFileXLS FILE &cFile
Xls Col 1 Width 1 OF oFileXls
Xls Col 2 Width 10 OF oFileXls
Xls Col 3 Width 10 OF oFileXls
Xls Col 4 Width 30 OF oFileXls
Xls Col 5 Width 30 OF oFileXls
Xls Col 6 Width 10 OF oFileXls
Xls Col 7 Width 10 OF oFileXls
Xls Col 8 Width 10 OF oFileXls
o : nRowXls++
@ o : nRowXls, 2 Xls Say o : cEmpresa Font nFont1 OF oFileXls Alignament ALING_LEFT
o : nRowXls++
@ o : nRowXls, 2 Xls Say 'LISTADO DE FACTURAS ' + If( !Empty( cTitulo ), cTitulo, '' ) Font nFont3 OF oFileXls Alignament ALING_LEFT
o : nRowXls++
@ o : nRowXls, 2 Xls Say 'F. DE EMISIÓN: ' Font nFont3 OF oFileXls Alignament ALING_LEFT
@ o : nRowXls, 4 Xls Say DToC( Date() ) Font nFont2 OF oFileXls Alignament ALING_LEFT
o : nRowXls++
o : nRowXls++
o : nRowXls++
o : nRowXls++
@ o : nRowXls, 2 Xls Say 'Nº FACT' Font nFont2 OF oFileXls Alignament ALING_LEFT BORDER_TOP + BORDER_LEFT + BORDER_BOTTOM
@ o : nRowXls, 3 Xls Say 'FECHA' Font nFont2 OF oFileXls Alignament ALING_LEFT BORDER_TOP + BORDER_BOTTOM
@ o : nRowXls, 4 Xls Say 'ALUMNO' Font nFont2 OF oFileXls Alignament ALING_LEFT BORDER_TOP + BORDER_BOTTOM
@ o : nRowXls, 5 Xls Say 'CONCEPTO' Font nFont2 OF oFileXls Alignament ALING_LEFT BORDER_TOP + BORDER_BOTTOM
@ o : nRowXls, 6 Xls Say 'IMPORTE' Font nFont2 OF oFileXls Alignament ALING_LEFT BORDER_TOP + BORDER_BOTTOM
@ o : nRowXls, 7 Xls Say 'ABONADO' Font nFont2 OF oFileXls Alignament ALING_LEFT BORDER_TOP + BORDER_BOTTOM
@ o : nRowXls, 8 Xls Say 'SALDO' Font nFont2 OF oFileXls Alignament ALING_LEFT BORDER_TOP + BORDER_RIGHT + BORDER_BOTTOM
o : nRowXls++
@ o : nRowXls, 2 Xls Say '' Font nFont3 OF oFileXls Alignament ALING_CENTER BORDER_LEFT
@ o : nRowXls, 8 Xls Say '' Font nFont3 OF oFileXls Alignament ALING_CENTER BORDER_RIGHT
o : nRowXls++
While( !oRec : Eof() )
@ o : nRowXls, 2 Xls Say StrZero( Val( o : nPtoVta ), 4 ) + '-' + StrZero( oRec : id_factura, 6 ) Font nFont3 OF oFileXls Alignament ALING_CENTER BORDER_LEFT
@ o : nRowXls, 3 Xls Say DToC( oRec : fecha ) Font nFont3 OF oFileXls Alignament ALING_CENTER
@ o : nRowXls, 4 Xls Say oRec : alumno Font nFont3 OF oFileXls Alignament ALING_LEFT
@ o : nRowXls, 5 Xls Say oRec : concepto Font nFont3 OF oFileXls Alignament ALING_LEFT
oFileXls : Number( o : nRowXls, 6, oRec : importe, .f., .f., nFont5, nFormat2 )
nImporte += oRec : importe
oFileXls : Number( o : nRowXls, 7, oRec : pagado, .f., .f., nFont5, nFormat2 )
nAbonado += oRec : pagado
oFileXls : Number( o : nRowXls, 8, oRec : importe - oRec : pagado, .f., .f., nFont5, nFormat2, .f., BORDER_RIGHT )
nSaldo += oRec : importe - oRec : pagado
oRec : Skip()
o : nRowXls++
Enddo
@ o : nRowXls, 2 Xls Say '' Font nFont3 OF oFileXls Alignament ALING_CENTER BORDER_LEFT
@ o : nRowXls, 8 Xls Say '' Font nFont3 OF oFileXls Alignament ALING_CENTER BORDER_RIGHT
o : nRowXls++
@ o : nRowXls, 2 Xls Say '' Font nFont3 OF oFileXls Alignament BORDER_LEFT + BORDER_BOTTOM
@ o : nRowXls, 3 Xls Say '' Font nFont3 OF oFileXls Alignament BORDER_BOTTOM
@ o : nRowXls, 4 Xls Say '' Font nFont3 OF oFileXls Alignament BORDER_BOTTOM
@ o : nRowXls, 5 Xls Say '' Font nFont3 OF oFileXls Alignament BORDER_BOTTOM
oFileXls : Number( o : nRowXls, 6, nImporte, .f., .f., nFont5, nFormat2, .f., BORDER_BOTTOM )
oFileXls : Number( o : nRowXls, 7, nAbonado, .f., .f., nFont5, nFormat2, .f., BORDER_BOTTOM )
oFileXls : Number( o : nRowXls, 8, nSaldo, .f., .f., nFont5, nFormat2, .f., BORDER_RIGHT + BORDER_BOTTOM )
SET Xls To Printer Footer "Desarrollos Digitales" Top Margin 0.6 BOTTOM MARGIN 0.8 LEFT MARGIN 0 OF oFileXls GRIDLINES
EndXls oFileXls
MsgRun( "Exportando datos, espere por favor ...",, { || ShellExecute( o : oWndMain : hWnd,, cFile,,, 3 ) } )
Return 0