This little code make a big result.
- Code: Select all Expand view
...
oLbx:bRClicked := {| nRow, nCol | ;
Reporte( oLbx, "Title", .t., "Subtitle", ;
{ "0","0","C","C","D","N","N","0","0" } ) } // Columns Flageds
...
"0" - Hide column in report
"C" - Shown character content
"D" - Shown data character
"N" - Shown numeric character
The implement:
- Code: Select all Expand view
function Reporte( oRPTLbx, cTitle, lPreview, cTitle2, aQColunas, cdblFilter )
local oRpt
local nRecNo := If( Upper( oRPTLbx:cAlias ) != "ARRAY", ( oRPTLbx:cAlias )->( RecNo() ), 0 )
local aData := Eval( oRPTLbx:bLine )
local n
local nCharWidth
local oRPTFont1, oRPTFont2, oRPTFont3
public nCreditos := 0
public nDebitos := 0
nCharWidth := GetTextWidth( 0, "B", If( oRPTLbx:oFont != nil, oRPTLbx:oFont:hFont, 0 ))
DEFAULT cTitle := oRPTLbx:oWnd:cTitle, lPreview := .t., cdblFilter := {||.t.}
DEFINE PEN oPen1 WIDTH 1 COLOR nRGB(238,238,238)
DEFINE FONT oRPTFont1 NAME "ARIAL" SIZE 0,-8
DEFINE FONT oRPTFont2 NAME "ARIAL" SIZE 0,-8 BOLD
DEFINE FONT oRPTFont3 NAME "ARIAL" SIZE 0,-20 BOLD
if lPreview
REPORT oRpt TITLE CL_Nome, cTitle, cTitle2 PREVIEW ;
FOOTER CL_Endereco CENTER FONT oRPTFont1, oRPTFont2, oRPTFont3 // Str( oRpt:nPage, 3 )
else
REPORT oRpt TITLE CL_Nome, cTitle, cTitle2 ;
FOOTER CL_Endereco CENTER FONT oRPTFont1, oRPTFont2, oRPTFont3 // Str( oRpt:nPage, 3 )
endif
if Empty( oRpt ) .or. oRpt:oDevice:hDC == 0
return nil
else
Eval( oRPTLbx:bGoTop )
endif
if oRPTLbx:aColSizes == nil
oRPTLbx:aColSizes = Array( Len( aData ) )
for n = 1 to Len( aData )
oRPTLbx:aColSizes[ n ] = 80
next
else
if Len( oRPTLbx:aColSizes ) < Len( aData )
n = Len( oRPTLbx:aColSizes )
do while n++ < Len( aData )
AAdd( oRPTLbx:aColSizes, 80 )
end
endif
endif
for n = 1 to Len( aData )
if aQColunas <> nil
if aQColunas[ n ] = "0"
loop
else
if aQColunas[ n ] = "N"
RptAddColumn({ GenLocal( oRPTLbx:aHeaders, n ) },,;
{ GenBlock( oRPTLbx:bLine, n ) },;
Int( oRPTLbx:aColSizes[ n ] / nCharWidth ),{"@9"},{||2},.T.,,UPPER("RIGHT"),.F.,.T., )
else
RptAddColumn({ GenLocal( oRPTLbx:aHeaders, n ) },,;
{ GenBlock( oRPTLbx:bLine, n ) },;
Int( oRPTLbx:aColSizes[ n ] / nCharWidth ),{"@!"},{||2},.F.,,UPPER("LEFT") ,.F.,.T., )
endif
endif
else
if ValType( aData[ n ] ) != "N"
if IsNumeric( aData[ n ] )
RptAddColumn({ GenLocal( oRPTLbx:aHeaders, n ) },,;
{ GenBlock( oRPTLbx:bLine, n ) },;
Int( oRPTLbx:aColSizes[ n ] / nCharWidth ),{"@9"},{||2},.F.,,UPPER("RIGHT"),.F.,.T., )
else
RptAddColumn({ GenLocal( oRPTLbx:aHeaders, n ) },,;
{ GenBlock( oRPTLbx:bLine, n ) },;
Int( oRPTLbx:aColSizes[ n ] / nCharWidth ),{"@!"},{||2},.F.,,UPPER("LEFT") ,.F.,.T., )
endif
else
RptAddColumn({ GenLocal( oRPTLbx:aHeaders, n ) },,;
{ GenBlock( oRPTLbx:bLine, n ) },;
Int( oRPTLbx:aColSizes[ n ] / nCharWidth ),{"@E 999,999.99"},{||2},.T.,,UPPER("RIGHT"),.F.,.T., )
endif
endif
next
ENDREPORT
//oRpt:oDevice:SetLandScape()
//oRpt:CellView()
oRpt:bSkip = { || oRpt:Cargo := oRPTLbx:Skip( 1 ) }
oRpt:Cargo = 1
/* First line of title bold */
oRpt:oTitle:aFont[1]:= {|| 3 }
oRpt:oTitle:aFont[2]:= {|| 2 }
oRpt:oTitle:aFont[3]:= {|| 1 }
ACTIVATE REPORT oRpt ; // ON END ReporteTotal(oRpt) ;
FOR Eval( cdblFilter ) ;
WHILE If( Upper( oRPTLbx:cAlias ) == "ARRAY",;
oRpt:nCounter < Eval( oRPTLbx:bLogicLen ),;
oRpt:Cargo == 1 )
if Upper( oRPTLbx:cAlias ) != "ARRAY"
( oRPTLbx:cAlias )->( DbGoTo( nRecNo ) )
endif
oRPTLbx:Refresh()
oRPTFont1:End()
oRPTFont2:End()
oRPTFont3:End()
return nil