Is it possible to have a progressbar or a meter into oReport class.
Thanks in advance
Otto
Is it possible to have a progressbar or a meter into oReport class.
Thanks in advance
Otto
Hi Otto,
there is a dialog with message of page creation, you can use this dialog to put a progressbar, but the problem is to know how many pages has the report
to set the progressbar, you need to calculate this previus to send the report maybe an estimate or generate the report without preview and generate again to obtain the total pages, this is the same problem if you need to put page number like "pagen of totalpage" in this case I write this information at the end of report directly to the EMF files.
regards
Marcelo
You can't know the total pages that will be printed but you know the total lines to be printed.
You can implement progress bar on the basis of number of lines printed in comparison with the total lines to be printed. The point is how do we get a callback to our program whenever a line is printed.
We supply a bSkip block the Report class. For DBF, report class has a default bSkip block. But we can supply our own bSkip block. It is in this bSkip block you provide, you can capture the record number being printed and use it in your progress bar.
But I do not find any need for progress bar for reports because the preview generation shows the user some kind of progress and that is adequate in most circumstances.
function rg_kontroll_druck(oStam)
local oReport,oFont1, oFont2, oFont3, oPen1, oline,cTITLE:="Rechnungs-Zusammenstellung vom"
local anfang := date()-1
local ende := date()-1
local oDlg
local ok := .f.
*----------------------------------------------------------
DEFINE DIALOG oDlg RESOURCE "Vonbis" TITLE "Rechnungszusammenstellung"
REDEFINE GET anfang ID 101 of oDlg picture("@D") SPINNER
REDEFINE GET ende ID 102 of oDlg picture("@D") SPINNER
REDEFINE BUTTONBMP ID 2 OF oDlg ;
ACTION oDlg:END() CANCEL ;
BITMAP ".\bitmaps\Delete.bmp" TEXTRIGHT
REDEFINE BUTTON ID 1 OF oDlg ACTION (OK:=.T.,oDlg:END())
ACTIVATE DIALOG oDlg CENTERED
IF OK = .T.
DEFINE PEN oPen1 WIDTH 0.5
DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-9
DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-8
DEFINE FONT oFont3 NAME "ARIAL" SIZE 0,-14 BOLD
select umsatz
set order to tag u_renr
Go Top
REPORT oReport TITLE " ",cTITLE+" "+ dtoc(anfang)+" - "+dtoc(ende)," " LEFT ;
FONT oFont1,;
oFont2,;
oFont3 ;
PEN oPen1;
HEADER Setup():LizenzNehmer()," ", ALLTRIM("Erstellt: " + dtoc(date())+ " - "+time()) RIGHT;
FOOTER "Seite " + Str(oReport:nPage,3) RIGHT PREVIEW
COLUMN TITLE "Artnum" DATA umsatz->artnum SIZE 8 FONT 2
COLUMN TITLE "Bezeichnung" DATA umsatz->bezeichnun SIZE 26
COLUMN TITLE "an" DATA umsatz->datum1 SIZE 8 FONT 2
COLUMN TITLE "ab" DATA umsatz->datum2 SIZE 8 FONT 2
COLUMN TITLE "Menge" DATA umsatz->menge SIZE 5 PICTURE "999,999,999.9"
COLUMN TITLE "Preis" DATA umsatz->preis SIZE 6 PICTURE "999,999,999.99" FONT 2
COLUMN TITLE "Wert" DATA umsatz->wert TOTAL SIZE 8 PICTURE "999,999,999.99"
COLUMN TITLE "Anzhg" DATA iif(umsatz->Anzhg<>0, umsatz->Anzhg,"") TOTAL SIZE 8 PICTURE "999,999,999.99"
COLUMN TITLE "Barzhg" DATA iif(umsatz->Barzhg<>0, umsatz->Barzhg,"") TOTAL SIZE 8 PICTURE "999,999,999.99"
COLUMN TITLE "Karte" DATA iif(umsatz->Karte<>0, umsatz->Karte,"") TOTAL SIZE 8 PICTURE "999,999,999.99"
COLUMN TITLE "Scheck" DATA iif(umsatz->Scheck<>0, umsatz->Scheck,"") TOTAL SIZE 8 PICTURE "999,999,999.99"
COLUMN TITLE "Kredit" DATA iif(umsatz->Kredit<>0, umsatz->Kredit,"") TOTAL SIZE 8 PICTURE "999,999,999.99"
GROUP ON umsatz->renr HEADER xPADR(ALLTRIM(str(umsatz->renr)),85)+xPADr(ALLTRIM(umsatz->name),195)+dtoc(umsatz->datum) FOOTER "Summe" FONT 3
END REPORT
oReport:CellView()
oLine:= oReport:oTitle
oLine:aFont[2] := {|| 3}
ACTIVATE REPORT oReport ;
FOR umsatz->datum >=anfang .AND. umsatz->datum <= ende ;
ON STARTGROUP oReport:NewLine()
oPen1:End()
oFont1:End()
oFont2:End()
oFont3:End()
endif
return nil
//----------------------------------------------------------------------------//Otto,
It looks like the delay is because you are using a filter. Try it without the filter and see how fast it is (just for a test). If that solves the speed issue, then you could build a modified index and use scopes.
James
iif(umsatz->Anzhg<>0, umsatz->Anzhg,"") PICTURE "999,999,999.99"
umsatz->Anzhg PICTURE "@Z 999,999,999.99"select umsatz
index on umsatz->datum TAG TEMPDAT3 TO TEMP TEMPORARY FOR (umsatz->datum >= (anfang) .AND. umsatz->datum <= (ende))Otto,
>I changed the code and use now a temporary index instead of the filter.
Still a temp index will cause a lag since it needs to read the whole DBF. Why not use scopes? You may need to build a new permanant index including the date field at the start of the index. Then set the scope to the beginning and ending date. This will be very fast and you don't need a temp index.
index on dtos( datum ) + renr
Then set the scopes.
umsatz->(ordScope(0, dtos(anfang) ) // set top scope
umsatz->(ordScope(1, dtos(ende) ) // set bottom scope
umsatz->(dbgotop())
James
Otto,
After thinking about it, the scopes in my previous message aren't going to work since you need to group by renr. It is late here and I am not thinking clearly. I will get back to you in the morning.
James
index on dtos(field->datum)+str(field->renr) tag u_datrg //12
...
select umsatz
//index on umsatz->datum TAG TEMPDAT3 TO TEMP TEMPORARY FOR (umsatz->datum >= (anfang) .AND. umsatz->datum <= (ende))
set order to tag u_datrg
umsatz->(ordScope(0, dtos(anfang) )) // set top scope
umsatz->(ordScope(1, dtos(ende) ) ) // set bottom scope
umsatz->(dbgotop())Otto,
Glad to hear it. But, don't you need to group by the field "renr" also? If so, then it gets more complicated. I came up with an idea, but it will take some testing to figure out the details.
James
Otto,
for this topic I am happy using ADSRDD, because you can mix SQL with traditional table navigation,
in your case a simple select <colums> from <table> where <condition> order by <order> is the solution
you can try
regards
Marcelo
Hello james,
the report is grouped by the field - and displayed ok.
Best regards,
Otto
Hello Marcelo,
I will test ADS when I have more time.
Best regards,
Otto
#include "fivewin.ch"
REQUEST ADS
function main()
LOCAL oDlg, consulta := SPACE(400), oLbx, path := SPACE(80),;
connect, tipo := "CDX", hconn
RddRegister("ads",1)
RddSetDefault("Ads")
AdsSetServerType ( 1 ) // local
AdsSetFileType(3)
SET DELETED ON
adsRightsCheck( .F. )
DEFINE DIALOG oDlg RESOURCE "consulta"
REDEFINE COMBOBOX tipo ID 108 ITEMS {"NTX","CDX","ADT"} OF oDlg ;
ON CHANGE AdsSetFileType( IF( tipo == "NTX", 1, ;
IF( tipo == "CDX", 2, 3 ) ) )
REDEFINE GET path ID 102 OF oDlg
REDEFINE BUTTON ID 103 OF oDlg ACTION ( AdsDisconnect( hconn ),;
IF ( AdsConnect60( path , 1,"ADSSYS",,@hconn), ;
connect:setcolor(CLR_GREEN, CLR_GREEN),;
connect:setcolor(CLR_HRED, CLR_HRED ) ;
),;
connect:refresh() ;
)
REDEFINE SAY connect PROMPT " " ID 110 OF oDlg COLOR CLR_HRED, CLR_HRED
REDEFINE GET consulta ID 104 OF oDlg
REDEFINE BUTTON ID 106 OF oDlg ACTION resultado( consulta )
REDEFINE BUTTON ID 107 OF oDlg ACTION oDlg:end()
ACTIVATE DIALOG oDlg
dbcloseall()
AdsDisconnect( hconn )
return nil
FUNCTION resultado( consulta )
LOCAL oDlg, oLbx,e
ADSCreateSQLStatement("SQLarea",2)
IF ADSExecuteSQLDirect( consulta )
TRY
DEFINE DIALOG oDlg RESOURCE "resultado"
REDEFINE LISTBOX oLbx FIELDS ALIAS "SQLarea" ID 101 OF oDlg
REDEFINE SAY PROMPT "RESULTADO : " + ALLTRIM( STR ( SQLarea -> ( LASTREC() ) ) ) ID 200 OF oDlg COLOR CLR_BLUE
REDEFINE BUTTON ID 102 OF oDlg ACTION oDlg:end()
REDEFINE BUTTON ID 103 OF oDlg ACTION oLbx:report()
ACTIVATE DIALOG oDlg
sqlarea -> ( DBCLOSEAREA() )
CATCH e
? "COMANDO EJECUTADO"
END
ELSE
MSGINFO("Error en la ejecución de la consulta")
sqlarea -> ( DBCLOSEAREA() )
ENDIF
RETURN NILCONSULTA DIALOG 29, 88, 436, 141
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "ADS - SQL"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
CONTROL "", 108, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 40, 11, 49, 43
CONTROL "", 102, "EDIT", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 136, 11, 219, 12
CONTROL "conectar", 103, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 360, 11, 50, 14
CONTROL "", 104, "EDIT", ES_LEFT | ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 13, 40, 414, 57
CONTROL "Ejecutar", 106, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 376, 101, 50, 14
CONTROL "Salir", 107, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 376, 124, 50, 14
CONTROL "Local Path", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 94, 13, 40, 8
CONTROL "Consulta SQL", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 13, 29, 60, 8
CONTROL "", 110, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 414, 11, 12, 12
CONTROL "Tipo", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 13, 12, 22, 8
CONTROL "", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 0, 428, 120
}
RESULTADO DIALOG 8, 27, 400, 188
STYLE DS_SYSMODAL | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "RESULTADO CONSULTA"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
CONTROL "", 101, "TWBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 5, 7, 390, 159
CONTROL "Salir", 102, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 345, 171, 50, 14
CONTROL "RESULTADO", 200, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 174, 93, 8
CONTROL "Reporte", 103, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 294, 171, 50, 14
}