I did it more than 20 years ago using FW 16 bits. I remember it was a bit tricky, using the DelColumn and AddColumn methods with bPostEnd block but it worked flawlessly. For a reason I could not discover the upgrade to FWH broke my code. As it coincided with the closing of the company I was working I did not dig it anymore. Here is the interesting part of the code:
Code: Select all
...................
REPORT oReport ;
CAPTION "BOLETIM DIÁRIO DE BANCO" ;
TITLE "BOLETIM DIÁRIO DE BANCO" ;
HEADER fantasia + xPadL( space( 30 ), 700 ) + "Nº" + allTrim( cNumbol ) + if( nLetra > 64, "-" + chr( nLetra ), "" ), razao + xPadL( space( 30 ), 600 ) + dToC( dDatc );
FONT oFont, oFon2 PREVIEW
COLUMN TITLE "Doc." DATA temp->DOC LEFT GRID
COLUMN TITLE "Histórico" DATA " " SIZE 50 GRID
COLUMN TITLE "Banco" DATA " " CENTER GRID
COLUMN TITLE "Cheque" DATA " " CENTER GRID
COLUMN TITLE "Entrada" DATA " " RIGHT GRID
COLUMN TITLE "Saída" DATA " " RIGHT GRID
END REPORT
IF oReport:lCreated
nMarg := oReport:Margin
oReport:bStdFont := { || 1 }
oReport:bStartRecord := { || ChkNewPg(), SayTran() }
oReport:bPostEnd := { || SayTotal( dDatc, nMarg ) }
oReport:oTitle:aFont[ 1 ] := {|| 2 }
oReport:oHeader:aFont[ 1 ] := { || 2 }
ENDIF
ACTIVATE REPORT oReport ON CHANGE SayMemo( @aSubt )
.................
STATIC FUNCTION SayMemo
local cText := allTrim( temp->HIS )
local cLine := ""
local nFor := 1
local nLines := MlCount(cText,50)
oReport:BackLine( 1 )
FOR nFor := 1 TO nLines
cLine := MemoLine(cText, 50, nFor)
oReport:StartLine()
oReport:Say(2,cLine)
if nFor = nLines
oReport:Say( 3, temp->BCO, 1, RPT_CENTER )
oReport:Say( 4, temp->CHQ, 1, RPT_CENTER )
oReport:Say( 5, Virg( temp->ENT, 12 ), 1, RPT_RIGHT )
oReport:Say( 6, Virg( temp->SAI, 12 ), 1, RPT_RIGHT )
endif
oReport:EndLine()
NEXT
aSubt[ 1 ] += temp->ENT
aSubt[ 2 ] += temp->SAI
oReport:Newline()
RETURN NIL
STATIC PROCEDURE SaySubt
if temp->( !eOF() )
oReport:BackLine( 1 )
oReport:grid()
oReport:Say( 2, " A T R A N S P O R T A R", 2 )
oReport:Say( 5, Virg( aSubt[ 1 ], 12 ), 2, RPT_RIGHT )
oReport:Say( 6, Virg( aSubt[ 2 ], 12 ), 2, RPT_RIGHT )
lTran := .t.
endif
return
STATIC PROCEDURE SayTran
if lTran .and. nLetra > 64
oReport:newLine()
oReport:Say( 2, "T R A N S P O R T E", 2 )
oReport:Say( 5, Virg( aSubt[ 1 ], 12 ), 2, RPT_RIGHT )
oReport:Say( 6, Virg( aSubt[ 2 ], 12 ), 2, RPT_RIGHT )
oReport:endLine()
oReport:newLine()
lTran := .f.
endif
return
STATIC FUNCTION ChkNewPg()
if oReport:nRow + ( ( MlCount( allTrim( temp->HIS ), 50 ) + 1 ) * oReport:nStdLineHeight ) >= ( oReport:nBottomRow - oReport:nStdLineHeight )
SaySubt()
oReport:nRow := oReport:nBottomRow
nLetra ++
endif
return ( NIL )
STATIC PROCEDURE SayTotal( dDatc, nMarg )
oReport:Separator( , oReport:nRow )
oReport:grid()
oReport:Say( 2, "T O T A L", 2 )
oReport:Say( 5, Virg( aSubt[ 1 ], 12 ), 2, RPT_RIGHT )
oReport:Say( 6, Virg( aSubt[ 2 ], 12 ), 2, RPT_RIGHT )
oReport:endLine()
oReport:Separator( , oReport:nRow )
SaySaldos( dDatc )
return
STATIC PROCEDURE SaySaldos( dDatc, nMarg )
local nTot_ant := 0
local nTot_nov := 0
local nI := 1
local nBanc := 0
local oColumn := NIL
local aTota := { 0, 0, 0, 0 }
local lNpag := .f.
local nPosi := 0
bancos->( ordSetFocus( 0 ), dbGoTop(), dbEval( { || nBanc += if( bancos->abertura <= dDatc .and. ( empty( bancos->FECHADA ) .or. bancos->FECHADA >= dDatc ), 1, 0 ) } ) )
if oReport:nRow >= ( oReport:nBottomRow - ( ( nBanc + 6 ) * oReport:nStdLineHeight ) )
oReport:Say( 2, "FECHAMENTO NA PROXIMA FOLHA", 2 )
oReport:EndPage()
lNpag := .t.
nLetra ++
endif
nPosi := ( oReport:nRow + oReport:nStdLineHeight )
oReport:DelColumn( 6 )
oReport:DelColumn( 5 )
oReport:DelColumn( 4 )
oReport:DelColumn( 3 )
oReport:DelColumn( 2 )
oReport:DelColumn( 1 )
dbSelectArea( "bancos")
bancos->( ordSetFocus( 2 ), dbgotop() )
oColumn := TRColumn():New( {{|| "BANCO"}}, , {{|| bancos->NOME }}, 30, {} ,, .F., ,UPPER("LEFT"), .F., .T.,, oReport )
oReport:AddColumn( oColumn )
oColumn := TRColumn():New( {{|| "SALDO ANTERIOR"}}, , {{|| " " }},, {} ,, .F., ,UPPER("LEFT"), .F., .T.,, oReport )
oReport:AddColumn( oColumn )
oColumn := TRColumn():New( {{|| " ENTRADA"}}, , {{|| " " }},, {} ,, .F., ,UPPER("LEFT"), .F., .T.,, oReport )
oReport:AddColumn( oColumn )
oColumn := TRColumn():New( {{|| " SAÍDA"}}, , {{|| " " }},, {} ,, .F., ,UPPER("LEFT"), .F., .T.,, oReport )
oReport:AddColumn( oColumn )
oColumn := TRColumn():New( {{|| " SALDO ATUAL"}}, , {{|| " " }},, {} ,, .F., ,UPPER("LEFT"), .F., .T.,, oReport )
oReport:AddColumn( oColumn )
oReport:Margin( nMarg, 1 )
//oReport:Margin( 5, 1, 2 )
oReport:Stabilize()
if lNpag
oReport:StartPage()
else
oReport:nTitleRow := nPosi
oReport:ColTitle()
endif
while bancos->( !eOF() )
if bancos->abertura <= dDatc .and. ( empty( bancos->FECHADA ) .or. bancos->FECHADA >= dDatc )
oReport:NewLine()
oReport:grid()
oReport:Say( 1, bancos->NOME, 1 )
oReport:Say( 2, Virg( saldo( bancos->CODI, 2 ),12 ), 1, RPT_RIGHT )
oReport:Say( 3, Virg( saldo( bancos->CODI, 3 ),12 ), 1, RPT_RIGHT )
oReport:Say( 4, Virg( saldo( bancos->CODI, 4 ),12 ), 1, RPT_RIGHT )
oReport:Say( 5, Virg( saldo( bancos->CODI, 5 ),12 ), 1, RPT_RIGHT )
oReport:EndLine()
aTota[ 1 ] += saldo( bancos->CODI, 2 )
aTota[ 2 ] += saldo( bancos->CODI, 3 )
aTota[ 3 ] += saldo( bancos->CODI, 4 )
aTota[ 4 ] += saldo( bancos->CODI, 5 )
endif
bancos->( dbSkip() )
enddo
oReport:TotalLine( RPT_SINGLELINE, 2 )
oReport:grid()
oReport:Say( 1, "TOTAIS", 2 )
oReport:Say( 2, Virg( aTota[ 1 ],12 ), 2, RPT_RIGHT )
oReport:Say( 3, Virg( aTota[ 2 ],12 ), 2, RPT_RIGHT )
oReport:Say( 4, Virg( aTota[ 3 ],12 ), 2, RPT_RIGHT )
oReport:Say( 5, Virg( aTota[ 4 ],12 ), 2, RPT_RIGHT )
oReport:EndLine()
oReport:TotalLine( RPT_SINGLELINE, 0 )
oReport:End()
return