FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to split a table by two columns
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
How to split a table by two columns
Posted: Sun Dec 31, 2017 02:27 PM
Hello,
thanks to “MULTI-LAYER” capabilities this does not need much code.

We have a typical report with a table inside.
The table is pretty lengthy and narrow, so we are thinking about splitting it in half and
placing the lower half next to the upper half like so:

Is there an easy way to account for variable-height rows, so if ABC rows are 5cm each and CDEF rows are just 1cm, the split is made like AB/CDEF ?
In EasyReport you do not need to use script code pure FIVEWIN is all you need.

This is the report I made with FW and ER:




The VRD files are like this:




And here is the source code you need:

Code (fw): Select all Collapse
FUNCTION DruckRegister()

   local oVRD
   local lPreview       := .t.
   local cDruckerName   := ""
   local cTemp          := ""
   local nNr            := 1
   local nColumn         := 1
   local cABC           := 0
   *----------------------------------------------------------
   use ( "sampleDbf" ) new
   select  sampleDbf
   index on field->betrieb  TAG TmpTag TO TEMPIndex TEMPORARY
   set order to tag TmpTag
   select  sampleDbf
   go top

   TPreview():lListViewHide := .T.
   EASYREPORT oVRD NAME ".\xVrd\sample.vrd"  PREVIEW  lPreview TO cDruckerName PRINTDIALOG IIF( lPreview, .F., .F. ) MODAL
   PRINTAREA 1 OF oVRD   ;
      ITEMIDS    { 100, 120 } ;
      ITEMVALUES { "My title", dtoc(  date() )  }

   do while .not. eof()
      nNr += 1
      if nColumn = 1
         if  UPPER( left( sampleDbf->BETRIEB, 1 ) ) <> cABc
            nNr += 2
            cABc := UPPER( left( sampleDbf->BETRIEB, 1 ) )
            PRINTAREA 5 OF oVRD ;
               ITEMIDS    { 100 } ;
               ITEMVALUES { cABc }
         endif
         PRINTAREA 3 OF oVRD ;
            ITEMIDS    { 101, 102 } ;
            ITEMVALUES { sampleDbf->BETRIEB,;
            STR( sampleDbf->nummer) }

      elseif nColumn = 2
         if  UPPER( left( sampleDbf->BETRIEB, 1 ) ) <> cABc
            nNr += 2
            cABc := UPPER( left( sampleDbf->BETRIEB, 1 ) )
            PRINTAREA 6 OF oVRD ;
               ITEMIDS    { 100 } ;
               ITEMVALUES { cABc }
         endif
         PRINTAREA 4 OF oVRD ;
            ITEMIDS    { 101, 102 } ;
            ITEMVALUES { sampleDbf->BETRIEB,;
            STR( sampleDbf->nummer) }
      endif

      if nNr > 65
         nNR := 0
         nColumn += 1

         PRINTAREA 2 OF oVRD
         if nColumn > 2
            nColumn := 1
            PAGEBREAK oVRD
            PRINTAREA 1 OF oVRD   ;
               ITEMIDS    { 100, 120 } ;
               ITEMVALUES { "RKSV - Register", dtoc(  date() )  }
         endif
      endif
      select  sampleDbf
      skip
   enddo

   oVRD:End()

RETURN NIL

//----------------------------------------------------------------------------//



Best regards,
Otto
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How to split a table by two columns
Posted: Sun Dec 31, 2017 02:39 PM

Very nice example

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion