FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Report group and header
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Report group and header
Posted: Mon Feb 24, 2025 01:33 PM
On report sample 10 (rep10.prg)

I saw there is the command for make a group
 GROUP ON Test->State ;
           FOOTER "Total State "+oReport:aGroups[1]:cValue+ ;
                  " ("+ltrim(str(oReport:aGroups[1]:nCounter))+")" ;
           FONT 2 ;
           EJECT

If I wish create a dialog before the rep10.prg and make a selection by user for select with a combobox the group comand How I must make ?

sample
@ 12, 10 COMBOBOX oRag[2] VAR nGroup ITEMS  aGroup  OF oDlgOptions SIZE 300, 30 PIXEL FONT oFont HEIGHTGET 16

How do I connect the user's choice to the group that has to make the report class?

then on header ( rep10)

  REPORT oReport TITLE  "*** My First Report ***"  ;
          FONT oFont1, oFont2 ;
          PREVIEW
I with insert the pages and the total pages

I tried with

local nTotalpages:= oReport:oDevice:cLastPage

HEADER ' ', "Data: "+dtoc(date())+ " Pagina.: "+str(oReport:nPage,3)+"/"+nTotalpages

But not run
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Report group and header
Posted: Mon Feb 24, 2025 04:58 PM
Dear Silvio,

Using the xcommand you get the oGroup object:
#xcommand GROUP [ <oRptGrp> ] ;
                [ ON <bGroup> ] ;
                [ HEADER <bHead> ] ;
                [ FOOTER <bFoot> ] ;
                [ FONT <uFont> ] ;
                [ <lEject:EJECT> ] ;
        => ;
        [ <oRptGrp> := ] RptAddGroup( <{bGroup}>, <{bHead}>, ;
                <{bFoot}>, <{uFont}>, <.lEject.> )
So you can modify the oGroup DATAs:
     DATA oReport
     DATA aTotal
     DATA bGroup, bHeader, bFooter, bHeadFont, bFootFont
     DATA cValue, cOldValue
     DATA nCounter, nHeaderHeight, nFooterHeight, nOrder
     DATA lEject, lNeedStart, lHeader, lFooter
     DATA Cargo
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Report group and header
Posted: Tue Feb 25, 2025 10:34 AM
Antonio Linares wrote: Dear Silvio,

Using the xcommand you get the oGroup object:
#xcommand GROUP [ <oRptGrp> ] ;
                [ ON <bGroup> ] ;
                [ HEADER <bHead> ] ;
                [ FOOTER <bFoot> ] ;
                [ FONT <uFont> ] ;
                [ <lEject:EJECT> ] ;
        => ;
        [ <oRptGrp> := ] RptAddGroup( <{bGroup}>, <{bHead}>, ;
                <{bFoot}>, <{uFont}>, <.lEject.> )
So you can modify the oGroup DATAs:
     DATA oReport
     DATA aTotal
     DATA bGroup, bHeader, bFooter, bHeadFont, bFootFont
     DATA cValue, cOldValue
     DATA nCounter, nHeaderHeight, nFooterHeight, nOrder
     DATA lEject, lNeedStart, lHeader, lFooter
     DATA Cargo
as I already explained to you, it's not that I don't know how to do the GROUP in the REPORT CLASS

the problem is different





I want to let the user select the group to group through a combobox, I use Tdatabase

1) if I use the xbrowse bsetup ( oBrw:report)
AAdd(oRep:aGroups,trGroup():New( bCampo2( afields, nGroup,oDbf ),; //field
{|| aGroup[nGroup]+" :"+oRep:aGroups[1]:cValue},; //header
{|| "Total "+aGroup[nGroup]+": "+oRep:aGroups[1]:cValue+" ("+ltrim(str(oRep:aGroups[1]:nCounter))+")"},; //footer
{|| 1 },; // Font
.f.,oRep))


Static function bCampo2( aCampos, nFor,oDbf ) //tdatabase
return (fieldWBlock(aCampos[nFor],oDbf:nArea ))

2) if I use the Report class directly
I have difficulty inserting a Macro example:
fieldname:= agroup[nselect][1]
fieldtitle:= agroup[nselect][2]

GROUP ON ::oDbf:&fieldname;
HEADER fieldtitle +"» "+::oReport:aGroups[1]:cValue ;
FOOTER fieldtitle +"» "+::oReport:aGroups[1]:cValue +;
"("+ltrim(str(::oReport:aGroups[1]:nCounter))+")" ;
FONT 1
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Report group and header
Posted: Tue Feb 25, 2025 01:10 PM
now i changed the selection combobox putting "none" in third place



then before to call oBrw:report() I made
 
    If nGroup>1
         aGroupby  := {nGroup}
      elseif  nGroup==3   //none
         aGroupby  := {}
      Endif

//index the dbf
   IF  oDbf != NIL
      If nGroup >1  .and.  nGroup < 3
        oDbf:setorder(nGroup)
        oDbf:gotop()
        oBrw:oDbf:SetOrder(nGroup)
        oBrw:oDbf:Gotop()
        xbrowser oBrw:odbf
        xbrowser oDbf

     elseif  nGroup==3    //none
        oBrw:SetOrder()
      Endif
  Endif

call oBrw:report

oBrw:Report( cTitle, , , ;
{ |oRep, oBrw| MySetUp( oRep, oBrw, oDbf,aGroup,nGroup,lEject,aCampi ) },,,aCols )

this is the result of group




two questions

1) I wish a line after the header of group where you see the orange arrow




2) the alternate lines do not work, I tried with the normal report class and with these commands it seems to work

on report normal
oReport:oShdBrush  := TBrush():New(,nRgb(219,229,241))
     AEval( oReport:aColumns, { | o | o:lShadow := ! o:lShadow } )
    oReport:bStartLine := { || IF(oReport:nCounter % 2 = 0 , oReport:lShadow :=.F.,oReport:lShadow :=.T.)   }
If I insert the same lines on mysetup of xbrowse
 
    oRep:oShdBrush := TBrush():New(,nRgb(219,229,241))
     AEval( oRep:aColumns, { | o | o:lShadow := ! o:lShadow } )
     oRep:bStartLine := { || IF(oRep:nCounter % 2 = 0 , oRep:lShadow :=.F.,oRep:lShadow :=.T.)   }
Not run, why ?


but I discovered a bug a long time ago

I 'm talking of MakeRepCol( oRep, oXCol ) function

I discovered when call RptAddColumn() shadow value is .f.
oCol := RptAddColumn( aHeader, nil ,;
                            { bData }, nSize, nil ,;
                            nil, nil, nil ,;
                            "RIGHT", .F., .F., nil, ;
                            nil, nil, ;
                            nil, nil, nil, nil, nil, ;
                            nil, nil, nil, nil, nil, nil, ;
                            nil, ;
                            XEval( oxCol:nProgTot , oxCol ), aClr )
the lshadow is the ten value and it is FALSE

question
how can it work if the value is always false?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Report group and header
Posted: Tue Feb 25, 2025 01:37 PM
Solution for me


Report( cTitle, lPreview, lModal, bSetUp, aGroupBy, cPDF, aCols , lShadow )

local oRep, oPrn, oFont, oBold, uRet
local nFor, uBookMark
local oBrw := Self
local lAddCols := .T.
local nRows, nSel, n
local lEof := .f.
local lSetUpTwice := .f.
local nLevels
local nRowSel := ::nRowSel

DEFAULT cTitle := If( ::oWnd:ClassName == 'TPANEL', ::oWnd:oWnd:cTitle, ::oWnd:cTitle )
DEFAULT lPreview := .T.
DEFAULT lModal := .T.
DEFAULT lShadow :=.f.


....


for nFor := 1 to Len( aCols )
if AScan( aGroupBy, { |o| o:nCreationOrder == aCols[ nFor ]:nCreationOrder } ) == 0
MakeRepCol( oRep, aCols[ nFor ], lShadow )
endif


static function MakeRepCol( oRep, oXCol,lshadow )
....
oCol := RptAddColumn( aHeader, nil ,;
{ bData }, nSize, nil ,;
nil, nil, nil ,;
"RIGHT", lShadow, .F., nil, ;
nil, nil, ;
nil, nil, nil, nil, nil, ;
nil, nil, nil, nil, nil, nil, ;
nil, ;
XEval( oxCol:nProgTot , oxCol ), aClr )


suggestions ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion