Report group and header

Post Reply
User avatar
Silvio.Falconi
Posts: 7151
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Report group and header

Post by Silvio.Falconi »

On report sample 10 (rep10.prg)

I saw there is the command for make a group

Code: Select all | Expand

 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

Code: Select all | Expand

@ 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)

Code: Select all | Expand

  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
User avatar
Antonio Linares
Site Admin
Posts: 42575
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 36 times
Been thanked: 84 times
Contact:

Re: Report group and header

Post by Antonio Linares »

Dear Silvio,

Using the xcommand you get the oGroup object:

Code: Select all | Expand

#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:

Code: Select all | Expand

     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
User avatar
Silvio.Falconi
Posts: 7151
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Report group and header

Post by Silvio.Falconi »

Antonio Linares wrote: Mon Feb 24, 2025 4:58 pm Dear Silvio,

Using the xcommand you get the oGroup object:

Code: Select all | Expand

#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:

Code: Select all | Expand

     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


Image


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)

Code: Select all | Expand

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))


Code: Select all | Expand

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:

Code: Select all | Expand

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
User avatar
Silvio.Falconi
Posts: 7151
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Report group and header

Post by Silvio.Falconi »

now i changed the selection combobox putting "none" in third place

Image

then before to call oBrw:report() I made

Code: Select all | Expand

 
    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

Image


two questions

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

Image


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

Code: Select all | Expand


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

Code: Select all | Expand

 
    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.

Code: Select all | Expand

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
User avatar
Silvio.Falconi
Posts: 7151
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Report group and header

Post by Silvio.Falconi »

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
Post Reply