Page 1 of 1

class to make Report with tdatabase

Posted: Fri May 31, 2019 8:37 am
by Silvio.Falconi
I tried to make a report with tdatabase and I have this error

Code: Select all

#include "fivewin.ch"
#include "report.ch"

REQUEST DBFCDX

STATIC oReport


Function test()

  RDDSetDefault( 'DBFCDX' )

      SET DATE FORMAT "dd/mm/yyyy"
      SET DATE ITALIAN
      SET CENTURY ON
      SET EPOCH TO ( YEAR( DATE() ) - 50 )



TRepTariffe():New():Attivare()

return nil

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

CLASS TRepTariffe
   DATA cPath init cFilePath(GetModuleFileName( GetInstance() ))  + "Data\"
   DATA oReport
   DATA oTariffeReport
   DATA oFont

   METHOD New() CONSTRUCTOR
   METHOD Attivare()

END CLASS

METHOD New() CLASS TRepTariffe

     ::oTariffeReport:= TDatabase():Open( , ::cPath+"TARIFFE", "DBFCDX", .t. )
     ::oTariffeReport:setorder(1)


     /*
     ::oTariffeReport:Exec( < ||
     SET FILTER TO  FIELD->IDLISTINO = strzero(nListino,2)
      return nil
              > )
       */

     // xbrowser ::oTariffeReport

   DEFINE FONT ::oFont NAME "Tahoma" SIZE 0,-10



   REPORT ::oReport                            ;
      TITLE  "ELENCO TARIFFE"             ;
      FONT   ::oFont                           ;
      HEADER "Data: "  + DTOC( DATE() )      ,;
           "stabilimento bagno"                      ,;
           "stabilimento bagno"                    ,;
           "1234567890"      LEFT            ;
      FOOTER "Pagina: " + STR( ::oReport:nPage, 3 ) RIGHT  ;
      PREVIEW

   COLUMN TITLE "TIPO  "       DATA ::oTariffeReport:tipo
   COLUMN TITLE "ELEMENTO   "  DATA ::oTariffeReport:elemento
   COLUMN TITLE "SERVIZIO"     DATA ::oTariffeReport:servizio
   COLUMN TITLE "SETTORE  "    DATA ::oTariffeReport:settore
   COLUMN TITLE "GIORNI"       DATA ::oTariffeReport:giorni
   COLUMN TITLE "PREZZO   "    DATA ::oTariffeReport:costo     PICTURE "99,999.99" RIGHT  SHADOW

   END REPORT

   RETURN Self

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

METHOD Attivare() CLASS TRepTariffe

   ::oTariffeReport:GoTop()

   ::oReport:bSkip := { || ::oTariffeReport:Skip(1) }
   ::oReport:Cellview()

   ACTIVATE REPORT ::oReport  WHILE !::oTariffeReport:eof()

   ::oFont:End()

   ::oTariffeReport:Close()

RETURN NIL





















Now print one page ok and one blank as you can see here

Image

Re: class to make Report with tdatabase

Posted: Fri May 31, 2019 9:36 pm
by leandro
Mira si ayuda

Code: Select all

********************
*IMPRIME EN PANTALLA
********************
PROC pIPCaj()
local oReport,nLinea := 1, nHasta := oRsCajaRg:RECORDCOUNT(), ;
nBookMark := oRsCajaRg:BookMark
oRsCajaRg:MoveFirst()
uFec:=dtoc(date())
uTim:=subs(time(),1,8)

REPORT oReport CAPTION "TABLA CONTROL CAJAS"  HEADER "CIUDADELA","NIT:"+"-","TABLA CONTROL DE DOCUMENTOS","Página Número: " + STR (oReport:nPage, 3),"Fecha Reporte: "+uFec+" - Hora: "+uTim;
CENTER  PREVIEW
  COLUMN TITLE "Código" DATA oRsCajaRg:Fields("kk_codigo"):value SIZE 9
  COLUMN TITLE "Nombre" DATA oRsCajaRg:Fields("kk_nombre"):value SIZE 25
END REPORT

oReport:bWhile := { || nLinea <= nHasta }
oReport:oDevice:SetPortrait()
oReport:oDevice:lPrvModal := .T.
IF oReport:lCreated
  oReport:bSkip := { | | nLinea++, oRsCajaRg:MoveNext() }
ENDIF

ACTIVATE REPORT oReport ;
ON END oRsCajaRg:BookMark := nBookMark
oRsCajaRg:REQUERY()
oBrwCReg:Refresh()

Re: class to make Report with tdatabase

Posted: Sat Jun 01, 2019 7:25 am
by Silvio.Falconi
STRANGE.....

this morning I add

DEFINE PEN ::oPen1 WIDTH 1 COLOR CLR_HGRAY
DEFINE PEN ::oPen2 WIDTH 1 COLOR CLR_BLACK

and

REPORT ::oReport ;
TITLE "ELENCO TARIFFE LISTINO ALTA STAGIONE" ;
FONT ::oFont ;
PEN ::oPen1,;
::oPen2
;
HEADER "Data: " + DTOC( DATE() ) ,;
"stabilimento bagno" ,;
"stabilimento bagno" ,;
"1234567890" LEFT ;
FOOTER "Pagina: " + STR( ::oReport:nPage, 3 ) RIGHT ;
PREVIEW



and now seem print ok as you can see here ...very very strange

Image

Someone among the Gurus and Masters (Nages, CNavarro, Linares ...) can explain to me why it didn't work before and now with the addition of only the Pen it seems that it prints everything well?

Re: class to make Report with tdatabase

Posted: Wed Jun 05, 2019 2:54 pm
by James Bott
It looks like the top and bottom margins may be set too narrow.

Re: class to make Report with tdatabase

Posted: Thu Jun 06, 2019 6:43 am
by Silvio.Falconi
I was not talking about the margins, I was talking about the fact that he first printed a page and a white page, then inserting the pages he printed part of the archive

Re: class to make Report with tdatabase

Posted: Thu Jun 06, 2019 4:09 pm
by James Bott
Silvio,

I was just saying that if you try to print past the margin you could get a page feed, and thus a blank page. Just a thought. Easy to test.