function testreport()
local oFr
oFr := frReportManager():New()
oFr:LoadLangRes( "German.xml" )
oFr:SetIcon( 1 )
// zimaed is my dbf file and it is in use
oFr:SetWorkArea("zimaed", SELECT("zimaed"))
oFr:SetTitle( "Zimmermaedchenliste" )
//I use this trick so I can handle individual report templates for different clients.
//If there is an individual template this is used otherwise the standard one.
if file( ".\REPS_MY\zimmermaedchenquer.FR3" ) = .t.
oFr:LoadFromFile( ".\REPS_MY\zimmermaedchenquer.FR3" )
else
oFr:LoadFromFile( ".\REPS\zimmermaedchenquer.FR3" )
endif
oFr:AddVariable( "FIRMA", "CompanyReport" , "'" + setup():LizenzNehmer +"'" )
oFr:AddVariable( "FIRMA", "cCompany" , "'" + cCompany +"'" )
oFr:AddVariable( "FIRMA", "cAddr1" , "'" + cAddr1 +"'" )
oFr:AddVariable( "FIRMA", "cAddr2" , "'" + cAddr2 +"'" )
oFr:AddVariable( "FIRMA", "cAddr3" , "'" + cAddr3 +"'" )
oFr:AddVariable( "FIRMA", "cTelefon" , "'" + cTelefon +"'" )
oFr:AddVariable( "FIRMA", "cFax" , "'" + cFax +"'" )
oFr:AddVariable( "FIRMA", "cEmail" , "'" + cEmail +"'" )
oFr:AddVariable( "FIRMA", "ComputerNr" , "' PC-Nr: " + cComputerNr +"'" )
oFr:AddVariable( "FIRMA", "Rooms", Setup():nRooms )
oFr:AddVariable( "FIRMA", "Beds", Setup():nBeds )
oFr:AddVariable( "FIRMA", "Rooms", Setup():nRooms )
oFr:AddVariable( "FIRMA", "Beds", Setup():nBeds )
oFr:AddVariable("Zeitraum", "VonBis", "'" + left( num2day( dow( ::dDay ) ),2 ) + " " + dtoc( ::dDay ) + "'")
//you can call scripts in your report - depending on the value I for example print a header or not
if ::lGruppenKopf = .t.
oFr:AddVariable("Einstellungen", "Gruppenkopf", "'JA'")
else
oFr:AddVariable("Einstellungen", "Gruppenkopf", "'NEIN'")
endif
oFr:AddVariable("Einstellungen", "TestLogischeVariable", .T. )
oFr:AddVariable("Einstellungen", "Sortierung", "'" + cSortierung + "'" )
//for calculating of sums, average etc. I prefer to use Fivewin and pass the results to the report.
//Errorhandling in FastReport (division through zero, etc.) is not that easy
oFr:AddVariable("Liste", "Erwachsene", sumerwachsene )
oFr:AddVariable("Liste", "Kinder", sumkinder )
oFr:AddVariable("Liste", "Zimmer", ZiSum )
oFr:AddVariable("Liste", "Anreisen", AnSum )
oFr:AddVariable("Liste", "Abreisen", AbSum )
// oFr:AddVariable("My Lovely Vars", "test", 100.25)
//oFr:AddVariable("My Lovely Vars", "test1", "'Test'")
//oFr:AddVariable("My Lovely Vars", "test2", ctod("01/01/2007"))
/*
aadd(adaten,{"name1","strasse1","ort1"})
aadd(adaten,{"name2","strasse2","ort2"})
aadd(adaten,{"name3","strasse3","ort3"})
oFr:SetUserDataSet("aDaten", "name;strasse;ort" , ;
{|| x := 1}, ; //--> bGoTop
{|| x := x + 1}, ; //--> bSkipPlus
{|| x := x - 1}, ; //--> bSkipMinus
{|| x > Len(aDaten)} , ; //--> bCheckEOF
{|aField| nCol := IIF( aField == "name", 1, (IIF( aField == "strasse", 2, 3 )) ), aDaten[x, nCol] } )
*/
//this is a trick I read in our forum.
//If you press the Control –key during execution of the report the report starts in design mode
if GETKEYSTATE(VK_CONTROL)
oFr:DesignReport()
else
****************************************************************************
//now the report is ready
****************************************************************************
//here you can use export
oFr:SetProperty("PDFExport", "FileName", ".\Myfile.pdf")
oFr:SetProperty("PDFExport", "UserPassword", "PW…" )
oFr:SetProperty("PDFExport", "OwnerPassword", "PW…" )
oFr:SetProperty("PDFExport", "OpenAfterExport", .f.)
oFr:SetProperty("PDFExport", "UserPassword", "test")
oFr:SetProperty("PDFExport", "ShowDialog",.f.)
oFr:PrepareReport()
oFr:DoExport("PDFExport")
and/or you can show the report on screen
oFr:ShowReport()
endif
oFr:DestroyFr()
return