FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TReport samples
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: TReport samples
Posted: Sun Apr 28, 2013 02:37 PM
Code (fw): Select all Collapse
#include "fivewin.ch"
#include "report.ch"

FUNCTION PrnDisVav
LOCAL dData := date() + 1
LOCAL oRepo
LOCAL oFon1
LOCAL oFon2

IF SeleDatRep( @dData )
    disv->( ordSetFocus( "DNOM" ), ordScope( 0, dToS( dData ) ), ordScope( 1, dToS( dData ) ), dbGoTop() )
    DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-8
    DEFINE FONT oFon2 NAME "ARIAL" SIZE 0,-10 BOLD
    REPORT oRepo TITLE  "ENTREGA DE VENDA AVULSA DE " + dToC( dData ), "JORNAL DO COMÉRCIO DE PETROLINA" ;
          FOOTER "PrnDisVav             Emissão:" + dToC( date() ) + " " + time() + " PAG:("+ allTrim( str( oRepo:nPage, 4 ) ) + ")", "" RIGHT CAPTION "RELATÓRIO PrnDisVav" FONT oFon1, oFon2 PREVIEW
        COLUMN TITLE "PONTO DE VENDA"       DATA disv->NOME 
        COLUMN TITLE "QTD"                  DATA disv->REPA TOTAL
        COLUMN TITLE "DETAILS"              DATA "" SIZE 40
    END REPORT
    IF oRepo:lCreated()
        oRepo:oTitle:aFont[ 1 ]:= { || 2 }
        oRepo:oTitle:aFont[ 2 ]:= { || 2 }
        oRepo:oHeader:aFont[ 1 ] := { || 2 }
        oRepo:Margin( .1, RPT_RIGHT )
        oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:oDevice:nLogPixelY, oRepo:nMargin/oRepo:oDevice:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:oDevice:nLogPixelY, RightMargin( oRepo ) / oRepo:oDevice:nLogPixelX , 1 )  }
    ENDIF
    ACTIVATE REPORT oRepo  ON CHANGE SayDetails( oRepo )
    oFon1:End()
    oFon2:End()
    disv->( ordScope( 0, NIL ), ordScope( 1, NIL ), dbSkip( 0 ) )
ENDIF
RETURN ( NIL )


FUNCTION RightMargin( oRepo )
LOCAL nRight := oRepo:nMargin

AEval( oRepo:aColumns, { | v | nRight += v:nWidth } )
nRight += ( ( Len( oRepo:aColumns )- 1 ) * oRepo:nSeparator )
RETURN nRight


FUNCTION SayDetails( oRepo )
LOCAL nI

oRepo:BackLine( 1 ) // remove this line if you want details to begin the line after master
FOR nI := 1 TO 4
    oRepo:StartLine()
    oRepo:Say( 3, "Detail " + str( nI ) )
    oRepo:EndLine()
NEXT
oRepo:Newline()
RETURN NIL
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 129
Joined: Sun Oct 09, 2011 03:50 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 01:22 PM
ADutheil wrote:The test I wrote seems OK:

It seems depend on the device - different printers give me different results. Perhaps TReport is performing some internal calculation which is wrong.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 02:11 PM

Mosh, André,

When fonts are going to be created for different printers, we should do:

DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-8 OF oPrinter

Where oPrinter is a PRINTER object previously created:

PRINTER oPrinter ...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 02:54 PM
Try this way:

Code (fw): Select all Collapse
FUNCTION PrnDisVav
LOCAL dData := date() + 1
LOCAL oRepo
LOCAL oFon1
LOCAL oFon2

IF SeleDatRep( @dData )
    disv->( ordSetFocus( "DNOM" ), ordScope( 0, dToS( dData ) ), ordScope( 1, dToS( dData ) ), dbGoTop() )
    DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-8
    DEFINE FONT oFon2 NAME "ARIAL" SIZE 0,-10 BOLD
    REPORT oRepo TITLE  "ENTREGA DE VENDA AVULSA DE " + dToC( dData ), "JORNAL DO COMÉRCIO DE PETROLINA" ;
          FOOTER "PrnDisVav             Emissão:" + dToC( date() ) + " " + time() + " PAG:("+ allTrim( str( oRepo:nPage, 4 ) ) + ")", "" RIGHT CAPTION "RELATÓRIO PrnDisVav" FONT oFon1, oFon2 PREVIEW
        COLUMN TITLE "PONTO DE VENDA"       DATA disv->NOME GRID
        COLUMN TITLE "QTD"                  DATA disv->REPA TOTAL GRID
        COLUMN TITLE "DETAILS"              DATA "" SIZE 40 GRID
    END REPORT
    IF oRepo:lCreated()
        oRepo:oTitle:aFont[ 1 ]:= { || 2 }
        oRepo:oTitle:aFont[ 2 ]:= { || 2 }
        oRepo:oHeader:aFont[ 1 ] := { || 2 }
        oRepo:Margin( .1, RPT_RIGHT )
        oRepo:bStartRecord := { || oRepo:separator() }
        //oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:nLogPixelY, oRepo:nMargin/oRepo:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:nLogPixelY, RightMargin( oRepo ) / oRepo:nLogPixelX , 1 )  }
    ENDIF
    ACTIVATE REPORT oRepo  ON CHANGE SayDetails( oRepo )
    oFon1:End()
    oFon2:End()
    disv->( ordScope( 0, NIL ), ordScope( 1, NIL ), dbSkip( 0 ) )
ENDIF
RETURN ( NIL )


FUNCTION RightMargin( oRepo )
LOCAL nRight := oRepo:nMargin

AEval( oRepo:aColumns, { | v | nRight += v:nWidth } )
nRight += ( ( Len( oRepo:aColumns )- 1 ) * oRepo:nSeparator )
RETURN nRight


FUNCTION SayDetails( oRepo )
LOCAL nI

//oRepo:BackLine( 1 )
oRepo:separator()
FOR nI := 1 TO 4
    oRepo:StartLine()
    oRepo:Say( 3, "Detail " + str( nI ) )
    oRepo:EndLine()
NEXT
oRepo:Newline()
RETURN NIL
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Re: TReport samples
Posted: Mon Apr 29, 2013 03:14 PM

André:

Can you show a sample of your report's output so we can learn of all the thing the code is doing ?

Thank you very much, muito obrigado.

Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 03:42 PM
With the 2 way. First one was already uploaded.



Uploaded with ImageShack.us
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 129
Joined: Sun Oct 09, 2011 03:50 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 05:32 PM
Antonio Linares wrote:Mosh, André,

When fonts are going to be created for different printers, we should do:

DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-8 OF oPrinter

Where oPrinter is a PRINTER object previously created:

PRINTER oPrinter ...


This produce huge font size and there is no place for report on a page.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 05:51 PM

Mosh,

Have you tried to use a smaller font size ? i.e.:

DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-4 OF oPrinter

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 07:30 PM

Antônio, I did try but had to go down to -1.

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 07:54 PM

André,

Ok, but did it properly shown on different printers ? thanks for the tests :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 08:57 PM

I just instaled another printer (Epson Stylus 85) and it did not work.

Actualy using oRepo:bStartRecord := { || oRepo:separator() } ( test version 2 ) it works. oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:oDevice:nLogPixelY, oRepo:nMargin/oRepo:oDevice:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:oDevice:nLogPixelY, RightMargin( oRepo ) / oRepo:oDevice:nLogPixelX , 1 ) } works with cutepdf writer but not with Epson. I probably messed something in the box params.

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 129
Joined: Sun Oct 09, 2011 03:50 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 09:22 PM
ADutheil wrote:I just instaled another printer (Epson Stylus 85) and it did not work.

Actualy using oRepo:bStartRecord := { || oRepo:separator() } ( test version 2 ) it works. oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:nLogPixelY, oRepo:nMargin/oRepo:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:nLogPixelY, RightMargin( oRepo ) / oRepo:nLogPixelX , 1 ) } works with cutepdf writer but not with Epson. I probably messed something in the box params.


I reduced font size to -1

Now the results of testing :

In CutePDF and Foxit Reader PDf Printer master data fits perfectly in the box. Microsoft Office Document Image Writer works too.

On preview

HP LaserJet 1300 data is not in the box. Dell Photo Printer 720 only half of the data row is in the box.

On printout

HP LaserJet 1300 only data upper part (like upper bar of of F) is in the box. Dell Photo Printer 720 only most of the data row is in the box.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 09:33 PM

Mosh,

Do the boxes look fine or the lines ?

If the lines are fine, then the box function may be wrong

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 129
Joined: Sun Oct 09, 2011 03:50 PM
Re: TReport samples
Posted: Mon Apr 29, 2013 10:36 PM
Antonio Linares wrote:Mosh,

Do the boxes look fine or the lines ?

If the lines are fine, then the box function may be wrong


I am using box, will try lines later.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TReport samples
Posted: Tue Apr 30, 2013 06:12 AM

I meant the text lines ? Do they look fine ?

Ib that case, we need to modify the Method Box()

regards, saludos

Antonio Linares
www.fivetechsoft.com