TReport samples

ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post by ADutheil »

Code: Select all

#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 BCC 5.82 MinGW 4.5.2 MSVS 10
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post by mosh1 »

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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TReport samples

Post by Antonio Linares »

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
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post by ADutheil »

Try this way:

Code: Select all

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: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 )
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 BCC 5.82 MinGW 4.5.2 MSVS 10
HunterEC
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: TReport samples

Post by HunterEC »

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.
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post by ADutheil »

With the 2 way. First one was already uploaded.

Image

Uploaded with ImageShack.us
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post by mosh1 »

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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TReport samples

Post by Antonio Linares »

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
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post by ADutheil »

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

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TReport samples

Post by Antonio Linares »

André,

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

Antonio Linares
www.fivetechsoft.com
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post by ADutheil »

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 BCC 5.82 MinGW 4.5.2 MSVS 10
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post by mosh1 »

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: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.
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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TReport samples

Post by Antonio Linares »

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
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post by mosh1 »

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.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TReport samples

Post by Antonio Linares »

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