0 evaluări0% au considerat acest document util (0 voturi)
76 vizualizări13 pagini
This document provides an introduction to Rave Reports and describes both code-based and visual designer approaches. It includes examples of simple code-based reports that output text and tables. It also demonstrates how to include graphics in code-based reports using images and shapes. The visual designer is introduced as an alternative that allows laying out reports visually without code. The interface and basic components are described.
This document provides an introduction to Rave Reports and describes both code-based and visual designer approaches. It includes examples of simple code-based reports that output text and tables. It also demonstrates how to include graphics in code-based reports using images and shapes. The visual designer is introduced as an alternative that allows laying out reports visually without code. The interface and basic components are described.
This document provides an introduction to Rave Reports and describes both code-based and visual designer approaches. It includes examples of simple code-based reports that output text and tables. It also demonstrates how to include graphics in code-based reports using images and shapes. The visual designer is introduced as an alternative that allows laying out reports visually without code. The interface and basic components are described.
Introduction to Rave Reports - Part I: Code Based Reports By: Leonel Togniolli Abstract: This is a introduction to Rave Reports. Part I describes how to work with Code Base reports. - by Leonel Togniolli Introduction to Rave Reports - Part I: Code Based Reports elphi ! has included Rave Reports as the de"ault reporting solution# replacing $uick Reports. %ince they work in very di""erent paradig&s# &any people were con"used by the new environ&ent. This is intended as an introduction "or people who haven't worked with Rave yet# and would like to start. elphi ! ships with Rave Reports (.).*. I" you haven't already# download the update "ro& the registered users page# since it "i+es so&e i&portant proble&s. ,ou can develop reports with Rave using two di""erent ways: Code Based or with the -isual esigner. This docu&ent describes how to work with the code based engine. Part II will describe the -isual esigner. Code Based Reports .ith Code Based# you write reports using plain elphi code. That provides a very "le+ible way displaying any kind o" data# allowing any kind o" co&ple+ layouts. To write a code based report# /ust drop a TRv%yste& co&ponent on the "or& and write the report on the 0nPrint event handler. %ender is the report you are creating# and can be typecasted to TBaseReport. It contains all the ðods you need to output in"or&ation to that particular report. Simple Code Base Report 1ere's a si&ple report using the code based &echanis&: procedure TFormMain.RvSystemPrintSender! T"#$ect%& begin with Sender as T'aseReport do begin SetFont()ria*(+ 1,%& -oto./1+1%& Print(0e*come to 1ode 'ased Reporting in Rave(%& end& end& To e+ecute this report# call Rv%yste&.2+ecute ðod. %o# what does that si&ple code do3 4irst# it calls %et4ont to select the "ont and si5e o" the te+t that will be printed "ro& that point on. Then it positions the cursor on the coordinates 67#78. These coordinates are e+pressed using the units set in the %yste&Printer.9nits property o" the Rv%yste& ob/ect# and it de"aults to Inches. ,ou can set it to un9ser and set a nu&ber relative to Inches in the %yste&Printer.9nits4actor property. 4or e+a&ple# i" 9nits4actor was set to ).( then 7 unit would correspond to hal" an inch. 4inally# the code calls the Print ðod to output the te+t. 1ere's the output: Tabular Code Based Report 1ere's another e+a&ple. It displays a list o" the "olders in the root o" the current drive# along with a recursive count o" nu&ber o" "iles and "older# and total si5e o" the "iles included in each "older. procedure TFormMain.PrintTa#u*arReportReport! T'aseReport%& var Fo*der2ist ! TString2ist& i ! Integer& 3umFi*es ! 1ardina*& 3umFo*ders ! 1ardina*& Si4eFi*es ! 1ardina*& Root ! string& begin with Report do begin SetFont()ria*(+ 1,%& 3e52ine& Print1enter(2ist o6 Fo*ders in t7e 8rive Root(+ 4%& 3e52ine& P a g e | 2 Introduction to Rave Reports - 2004 3e52ine& 1*earTa#s& SetTa#0.2+ p$2e6t+ 1.9+ 0+ 0+ 0%& SetTa#1.9+ p$Rig7t+ :.1+ 0+ 0+ 0%& SetTa#:.1+ p$Rig7t+ :.,+ 0+ 0+ 0%& SetTa#:.,+ p$Rig7t+ 4.,+ 0+ 0+ 0%& SetFont()ria*(+ 10%& 'o*d !; True& PrintTa#(Fo*der 3ame(%& PrintTa#(3um#er o6 Fi*es(%& PrintTa#(3um#er o6 Fo*ders(%& PrintTa#(Si4e o6 Fi*es(%& 'o*d !; Fa*se& 3e52ine& Fo*der2ist !; TString2ist.1reate& try Root !; Inc*udeTrai*ingPat78e*imiter<=tractFi*e8riveParamStr0%%%& <numFo*dersFo*der2ist+ Root%& for i !; 0 to Fo*der2ist.1ount - 1 do begin PrintTa#Fo*der2ist>i?%& -etFo*derIn6oInc*udeTrai*ingPat78e*imiterRoot@Fo*der2ist>i?%+ 3umFi*es+ 3umFo*ders+ Si4eFi*es%& PrintTa#Format(Au(+>3umFi*es?%%& PrintTa#Format(Au(+>3umFo*ders?%%& PrintTa#Format(Au #ytes(+>Si4eFi*es?%%& 3e52ine& end& fnally Fo*der2ist.Free& end& end& end& :otice that a di""erent approach has been taken: instead o" speci"ying the coordinates o" each te+t output# the printing was done using Lines and Colu&ns as re"erences. The line heigh depends on the si5e o" the current "ont: each unit represents 7;!<nds o" an inch# so each line printed with a si5e 7) "ont will have# apro+i&atelly# a height o" ).7=* inches. Lines are advanced a"ter calls to PrintLn or :ewLine. Colu&s are de"ined using calls to the %etTabs ðod# and the PrintTab ðod will print the te+t in the current colu&n and advance to the ne+t one. 1ere's the output: ,ou can "ind the "ull source# including the i&ple&entation o" 2nu&4olders and >et4olderIn"o# on CodeCentral. Graphical Code Based Report ,ou can include shapes and i&ages in your code based report# along with the te+t. The "ollowing e+a&ple de&onstrates that: procedure TFormMain.Print-rap7icsReportReport! T'aseReport%& var 'itmap ! T'itmap& begin with Report do begin 1anvas.'rus7.1o*or !; c*-ray& Rectang*e0.:+ 0.:+ 4.9+ :.:%& SetFont()ria*(+ 1,%& Font1o*or !; c*Red& P a g e | : Introduction to Rave Reports - 2004 Print./0.,+0.,+ (Bust *ooC at a** t7e grap7icsD(%& 'itmap !; T'itmap.1reate& try 'itmap.2oadFromFi*e(de*p7i.#mp(%& Print'itmap:.,+0.:+1+1+ 'itmap%& Print'itmap1+2+:+:+ 'itmap%& 1anvas.Pen.1o*or !; c*'*ue& 1anvas.'rus7.'itmap !; 'itmap& <**ipse,+0.:+E+:.:%& <**ipse2+1+4+1.F%& fnally 'itmap.Free& end& 1anvas.Pen.1o*or !; c*'*acC& 1anvas.'rus7.Sty*e !; #sSo*id& 1anvas.'rus7.1o*or !; c*/e**o5& Pie0.9+0.9+1.9+1.9+1+1+1+2%& 1anvas.'rus7.1o*or !; c*-reen& Pie0.9+0.9+1.9+1.9+1+2+1+1%& end& end& In this e+a&ple the ðods Rectangle# 2llipse and Pie have been used draw shapes with di""erent "ills. Bit&aps were outputted using PrintBit&ap and as the brush o" the ellipses. 1ere's the output: ? sa&ple application# containing "ull source code "or those three e+a&ples can be "ound at CodeCentral. Conclusion ?s you can see# code based reporting o""ers a great "le+ibility and control o" the layout you want# but re@uire so&e work to i&ple&ent the&. In Part II we will see how the -isual esigner can be used to build power"ul reports in a very easy way. Introduction to Rave Reports - Part II: -isual esigner By: Leonel Togniolli Abstract: This is a introduction to Rave Reports. Part II describes how to work with the -isual esigner - by Leonel Togniolli Introduction to Rave Reports - Part II: Visual Designer In the Part I o" this docu&ent# you have seen how the Code Based engine o" Rave Reports works. :ow we are going to e+plore the -isual esigner. The Visual Designer I" you are used to work with $uick Reports# the de"ault reporting engine included in the previous versions o" elphi# you created your reports using elphi's own "or& designer# and they were save in the 4A# included as resources in your e+ecutable. Rave works a bit di"erently in this aspect: it has it's own report designer# and saves the report using it's own "ile "or&at. This has so&e advantages# including the "act that your P a g e | 4 Introduction to Rave Reports - 2004 reports can be &ade BstandaloneB# and be used or updated independently o" your application# or even &ade available in a Intranet or in the Internet# using :evrona's Rave Report %erver. 0" course# you can still have it saved in a "or&'s 4A. To get started with the Rave -isual esigner# drop a TRvPro/ect in a "or&. This will be the link "ro& your application to the reports you are developing. I" you want# you can add a TRv%yste& and link your RvPro/ect to it# through it's 2ngine property. The Rv%yste& is the ob/ect responsible "or the general con"iguration o" the reports: the printer that is going to be used# the &argins# the nu&ber o" pages# and so on. To start a new pro/ect# double click the RvPro/ect you added to the "or&# or select BRave -isual esigner...B "ro& its conte+t &enu. This is the inter"ace that you will be working on: The inter"ace is si&ple# and you &ight be "a&iliar with so&e parts o" it "ro& elphi's I2. 0n the top there's the &enu# the toolbar# and the co&ponent pallete that contain the co&ponents that will be used in the reports. In the le"t there's the 0b/ect Inpector# which will be used to ad/ust the properties o" the co&ponents o" the report. In the &iddle there's the Page esigner or the 2vent 2ditor# and in the le"t there's the very use"ull Pro/ect Treeview. 4or a @uick overview o" the co&ponents in the pallete# you can go to :evrona's -isual esigner page. ? Rave Pro/ect 4ile can have one or &ore reports. That way you can keep co&&on ite&s between the& in a single location# called >lobal Pages. I" you e+pand the Report Library node o" the Pro/ect Treeview# you can see that right now you are working on Report7. Clicking on it# its properties will show on the Inspector. Let's change it's na&e and call it %i&pleReport. :e+t# go to the %tandard tab on the Co&ponent Pallete# and pick a Te+t co&ponent and add it to the page. Change its te+t property# and ad/ust its si5e and position. 1ere's how &ine looked like: ?s you can see# the properties that were changed "ro& the de"ault values are shown in bold. In this case# I changed the 4ont# Te+t and Truncate properties. By de"ault it does not highlight :a&e# Pos and %i5e changes. I" you'd like to see the&# right click the Inspector and uncheck B2+clude :a&e# %i5e and Pos changesB in the conte+t &enu. ,ou &ight have also noticed that Rave does not have an auto si5e property. ,ou can use the Truncate property to have that e""ect: i" truncate is "alse# the design ti&e si5e will have no e""ect. P a g e | , Introduction to Rave Reports - 2004 ,ou can see the result o" this si&ple report right on the designer: Press F9 or use File/Execute Report to run it. :ow let's do it in our application. %ave your pro/ect and return to elphi. Change to Pro/ect4ile property o" RvPro/ect to point to the "ile you /ust saved. To run the report# add a call to the 2+ecute ðod o" the RvPro/ect ob/ect in a button click# "or e+a&ple. RvPro/ect.2+ecute will only work "or now because we only have one report in this pro/ect. I" we had &ultiple reports# we'd have to call %electReport to choose one be"ore calling 2+ecute# or calling 2+ecuteReport directly. 1ere's the output: Tip: I" you Close and 0pen your pro/ect be"ore e+ecuting# you won't need to to reco&pile your application or restart it to see the changes you /ust &ade in the designer. Interacting with the Project I" you worked with $uick Reports# you &ight be used to &anipulating the ob/ects in runti&e# changing their Position# Te+t and -isibility. ?"ter all# they were /ust T0b/ectsC .hile this is possible with Rave# and I'll cover it in a later article# it's a little harder than it was with $R. But don't worry# Rave provides a di""erent answer to this kind o" proble&s. Parameters I" you can use para&eters in your reports. They can be de"ined using the para&eters property o" either the Pro/ect# a Report or a Page. Para&eters can be de"ined in either o" these places# they are /ust in &ultiple places "or easier access. ,ou can only select the Pro/ect and a Report through the Pro/ect Treeview. ? page# however# can be selected using the Pro/ect Treeview or clicking on it's title above the page designer. ?&ong other uses# you can print para&eters. %o# "or instance# i" the title o" your report can be user-de"ined# you could pass it "ro& your application into the report as a para&eter. Let's add a new report to this pro/ect to see how para&eters work. To do that# click the "ourth button on the toolbar or choose 4ile;:ew Report. Call it Para&etri5edReport# changing its na&e through the ob/ect inspector. This report is going to be very si&ilar to the "irst one# e+cept the te+t is going to be user-de"ined. :ow we need to de"ine the para&eter that is going to be printed. To do that# still having the report as the selected ob/ect# open the property editor the the para&eters property. There should be listed all para&eters o" this report# each on a separate line. ?dd a para&eter called :a&e# like this: Para&eters can be printed using a ataTe+t co&ponent# available in the Report tab o" the co&ponent pallete. ?dd a ataTe+t to the page# and open the property editor o" the ata4ield property. There you can choose which "ield is going to be printed# when working with ata?ware reports 6which will be covered on Part III o" these series8. ,ou can also choose Pro/ect -ariables# Para&eters and Post-Initiali5e -ariables "ro& there. %o choose the para&eter added previously "ro& the Para&eters drop-down co&bo and press the Insert Para&eter button. The data te+t e+pression is now Param!ame 6we are going to change that a little later8. Press 0D and try to e+ecute the report# as be"ore. :othing is printed# since the para&eter has not been set. .e need to set this para&eter be"ore printing. on't "orget to save your changes# and return to elphi# adding a call to %electReport be"ore 2+ecute# so we can see the right report. Be"ore e+ecuting# though# we need to set the para&eter we added. That is &ade using RvPro/ect's %etPara& ðod. This is how &y code looks like right now: procedure TFormMain.#tn<=ecute1*icCSender! T"#$ect%& begin RvPro$ect."pen& RvPro$ect.Se*ectReport(Parametri4edReport(+Fa*se%& RvPro$ect.SetParam(3ame(+(2eone*(%& RvPro$ect.<=ecute& RvPro$ect.1*ose& P a g e | E Introduction to Rave Reports - 2004 end& :ow# when we e+ecute the report# we are going to see the string we set as a para&eter printed. Tip: ,ou can use RvPro/ect.>etReportList to get a list o" avaible pro/ects# and add the& to a Co&boBo+# or a Radio>roup# "or e+a&ple. That &akes selecting the report easier. But this is too si&ple. Let's change the e+pression that is going to be printed. Return to Rave esigner and open the property editor "or the ataTe+t we added. ,ou can add any te+t you want# co&bining te+t# "ields# para&eters and variables. I changed it to this: 1ere's the result: Post"#nitiali$e %ariables Post-Initiali5e -ariables# or si&ply PI -ars# are variables whose value is only known a"ter the report has already been printed. It &ay sound strange# at "irst# but think about the nu&ber o" pages o" a report# "or e+a&ple. .e can only know it's value a"ter the report is ready. ?ctually TotalPages is a report variable that acts like a PI var# and can easily be printed using ataTe+ts as we did with Para&eters. Global Pa&es .hen you have parts o" reports that are co&&on to two or &ore reports# you can put these in a global page. Let's supose we have a header with our co&pany na&e# the date and ti&e that report is being printed# the current page and the nu&ber o" pages o" that report. .e want that header to be in every report. 1ow can we do it3 4irst# add a global page to the pro/ect# using 4ile;:ew >lobal Page# or the Toolbar shortcut. In that page# add a section co&ponent# available in the standard tab o" the co&ponent pallete. %ections are logical groupings o" co&ponents. they can be used to group co&ponent so they can be easily &oved around the report# or as containers "or Airrors# as we are doing right now. Inside that section we add what we want to be printed. In this case# a "ew ataTe+ts. Ay header looks like this: 1int: Instead o" changing the "ont property o" several co&ponents to the sa&e "ont# link the& to a 4ontAaster co&ponent# available in the standard tab# and set the "ont on it. That way is easier to change the "ont in the "uture# in case it's needed. :ow add another section to the Page7 o" %i&pleReport. %et its Airror property to >lobalPage7.%ection7. ,ou will see a copy o" the header you created in the global page. o the sa&e thing to Para&etri5edReport. :ow both reports share the sa&e header. 1ere how it looks like "or &e:
Conditional Printin& P a g e | 9 Introduction to Rave Reports - 2004 %o&eti&es we need to print certain parts o" a reporting depending o" so&e conditions. Rave has a very power"ul way o" dealing with this. .e can conditionally &irror sections depending on "ield values or para&eters. Let's create a new Report# calling it a ConditionalReport. Let's pretend that this new report is a trick one. The user can choose the header that is going to be printed# "ro& two di""erent kinds o" headers. 1e can also choose "or the report to be printed without a header. .e are going to use a para&eter to tell the report what kind o" header is going to be printed# and a ataAirror%ection to select the proper header at runti&e. 4irst# add a para&eter to this new report called 1eaderDind. Let's assu&e that it will have the values 1) 6"or no header8# 17 6"or the "irst header8# 1< 6"or the second kind o" header8. :ow add a new section to the global page 6you can reach it through the Pro/ect Treeview8# with the second kind o" header layout. I created a header si&ilar to the "irst one# changing the "ont title and adding a border around the values. It looks like this: :ow return to the Page7 o" ConditionalReport# and add a ataAirror%ection# available at the Report tab o" the co&ponent pallete. >o to its ata4ield property editor# and set Param'eader(ind as the e+pression. :ow go to the ataAirrors property editor# and add two ata Airrors: i" the value is 17# it should point to the "irst header# 1<# to the second. %ince 1) does not &atch any &irrors# nothing will be printed. It should look like this: :otice that I gave &ore &eaning"ul na&es to each o" the sections earlier. 1int: ,ou can use the 0nAirror-alue event o" the ataAirror%ection to work on ranges o" values. :ow return to elphi and add the code to set the para&eter according to the user's choice. I added a Co&boBo+ with the options and &y code looks like this: procedure TFormMain.#tn<=ecute1*icCSender! T"#$ect%& begin RvPro$ect."pen& RvPro$ect.Se*ectReportcm#Reports.Te=t+Fa*se%& case cm#Reports.ItemInde= of 1! RvPro$ect.SetParam(3ame(+ed3ame.Te=t%& 2! RvPro$ect.SetParam(GeaderHind(+Format(GAd(+>cm#GeaderHind.ItemInde=?%%& end& RvPro$ect.<=ecute& RvPro$ect.1*ose& end& :ow the proper header will be printed according to the user's choice. Embedding the Project in the Executable .hen you deploy your application# you &ust include you pro/ect "ile. ,ou can have it as a separated "ile# so you can update it in a easier way# only shipping a new one# without reco&piling your application# or include it in your e+ecutable. It's easy to do that: open the property editor "or the %toreR?- property o" RvPro/ect. There you can press Load to include the "ile in the 4A# %ave to e+tract a previously saved "ile# and Clear to re&ove an e&bedded "ile. .hen there's a "ile loaded in this property# you don't need to ship the pro/ect "ile separately. Conclusions .e've learned how to work on the -isual esigner# and seen a "ew tricks that allow so&e "le+ible reports. ,ou can "ind a pro/ect containing the sa&ple reports developed here on CodeCentral. 0n Part III we are going to learn how to create ata?ware reports# and operate with bands. P a g e | I Introduction to Rave Reports - 2004 Introduction to Rave Reports - Part III: ata ?ware Reports By: Leonel Togniolli Abstract: This is a introduction to Rave Reports. Part III describes how to create ata ?ware Reports using river ata -iews - by Leonel Togniolli Introduction to Rave Reports - Part III: Data Aware Reports In the previous articles# I have shown how do the Code Based engine and the -isual esigner work. In this docu&ent# I'& going to e+plore the ata- ?ware capabilities o" Rave Reports. The Database Connection There are two ways to access data "ro& inside a report: you can share the sa&e connection established by your application# "etching records "ro& atasets that e+ists in your 4or&s or ata&odules# or you can con"igure a new connection on the report# allowing it to be independent o" a particular application. 4or the "irst ðod you would use a )irect )ata %ie*# and a )ri+er )ata %ie* "or the second. ata -iew is the analog o" a ata%ource;ata%et co&bination inside the report. I" you intend to deploy your application using :evrona's Rave Report %erver# you should use river ata -iews. The )ri+er )ata %ie* Let's create a si&ple database report using a river ata -iew. %tart the Rave -isual esigner# and start a new pro/ect. .e need to de"ine the database connection. To do this# choose 4ile;:ew atabase 0b/ect# or press the si+th button in the toolbar 6the purple cube8. The )ata Connections window will appear: Choose )atabase Connection# and you will be asked which ata Link you are going to be using. There is a "older called ataLinks where Rave has been installed# containing so&e "iles with the .rvd e+tensions# responsible "ro& the connection &echanis&. By de"ault# you can choose between B2# b2+press and ?0. I'll be using B2 "or this e+a&ple. Choose B2# press 4inish# and the atabase Connection Para&eters window will show up. 2very ata Link has a di""erent set o" connection para&eters available# si&ilar to those available in the elphi I2. 4or now# /ust set ?lias to be&os and press 0D. :otice that a atabase ob/ect has been added to the Pro/ect Treeview# under ata -iew ictionary: :otice that the settings you con"igured in the atabase Connection Para&eters# a"ter the wi5ard# including userna&e and password# i" aplicable# were saved in the ?uthesign property o" the atabase co&ponent. In the ?uthRun property you can use di""erent settings to be used at runti&e# when your report has been deployed. .e are going to create now the river ata -iew. Click on :ew ata 0b/ect# then choose )ri+er )ata %ie*. ,ou should now choose the atabase Connection that is going to be used by this ata -iew: choose the atabase created in the previous step. ? $uery ?vanced esigner will show up. rag and rop the table custo&er.db "ro& the table list to the Layout window. It should look like this: P a g e | F Introduction to Rave Reports - 2004 I" you have &ore than one table# you should drag and drop "ields that should be /oined between tables. I" you press the Editor button you can check the generated %$L# or type-in a &ore co&ple+ @uery. Let's keep the si&ple Custo&er Listing "or now. Press 0D and a riverata-iew will be added to the Pro/ect Treeview# below the atabase co&ponents# having the selected "ields as subite&s: :otice that I rena&ed the atabase Connection and the ata -iewto &ore appropriate na&es. It's in the Treeview where properties o" the "ields should be set# like the isplay Label 6Full!ame property8# and the )ispla,Format. Re&ions and Bands Report co&ponents that should be printed in a "i+ed position in every page# like "i+ed headers and "ooters can be put directly in page. Co&ponents whose position will be dependent o" previously printed ite&s# should be put in bands. ataBands will be printed once "or every record in the linked ata-iew# while regular Bands will only be printed once# regardless o" how &any records have been selected. Both can contain ata-?ware co&ponents 6like ataTe+t8# or regular co&ponents 6like Te+t8. Bands should be put inside Regions. Regions deli&itate the width o" the bands# and the &a+i&u& height that bands can use be"ore starting a new page. 0ne page can have &any Regions# and one Region can contain &any Bands. ?dd a Region to the Page covering its whole area. Inside the region add a Band# to be used as the report header# a ataBand# to print the custo&er in"or&ation# and another Band# the report "ooter. I" you wish to change the ordering o" e+isting bands in a report# use the -o+e For*ard and -o+e Behind buttons in the ?lig&ent Toolbar. Rena&e the bands to &ore &eaning"ul na&es 6I used 1eader# Custo&erata and 4ooter8. %et the )ata%ie* property o" Custo&erata to vCusto&er# and set Custo&erata as the ControllerBand o" the 1eader and 4ooter bands. ,ou should also run the Band %tyle 2ditor# "ro& the 0b/ect Inspector# and set the Print .ocation o" those two bands to Bod, 'eader and Bod, Footer# respectively. ,ou can have an idea on how the report is going to be printed observing the Band isplay as you change the settings. It shows iterating bands repeated three ti&es# and other bands only once: .e also want the 1eader to be printed in other pages in case the listing spans &ore than one page: check the !e* Pa&e option in the Print /ccurrence groupbo+# in that sa&e dialog. The 4ooter band will only print when vCusto&ers has reached its end. I" you want it printed in every page# regardless o" that# /ust put the co&ponents directly on the page# below the region# and not in a Band. In the editor# you can @uickly identi"y the relationship between bands# their styles and their print occurrences: P a g e | 10 Introduction to Rave Reports - 2004 Addin& Fields It's not hard to add "ields to a report. ,ou can Ctrl0)ra& the "ields "ro& the ata-iew# in the Pro/ect Treeview# to add ataTe+t co&ponents to the report# and Alt0)ra& the& to add Te+t co&ponents containing the 4ullna&e property. This allows you to @uickly create the layout o" the report. :ow add so&e "ields to Custo&erata and their title to the 1eader. I added Cust:o# Co&pany# Phone# Ta+Rate and LastInvoiceate. on't "orget that you can use the tools on the ?lign&ent Toolbar to align the co&ponents# even i" they are in di""erent bands. I added a title to the 1eader band and a si&ple te+t to the 4ooter band# indicating that the listing has ended. Later on the series we are going to see how to use the Calc0p and CalcTotal co&ponents to be able to add totals# averages and other calculated values to the 4ooter. Addin& the Report to 1our Pro2ect To add this report to your pro/ect you should use use the sa&e approach as seen in Part II: /ust use a RvPro/ect in a 4or& or ataAodule# link it to the report "ile# and call it's 2+ecute ðod. But there is one gotcha when using river ata -iews: your application &ust load the apropriate driver. To do that# /ust add the unit RvLB2 to your uses clause# i" using B2# RvLBE i" using b2+press# or RvL?0 i" using ?0. Conclusions This article has shown how to develop si&ple ata?ware reports. ,ou can "ind a pro/ect containing the report developed here on CodeCentral. Part I- will de&onstrate the use o" irect ata -iew# show how to &ake Aaster;etail reports# and how to calculate values to display totals and calculated "ields. Introduction to Rave Reports - Part I-: Aore ata ?ware Reports By: Leonel Togniolli Abstract: T7is is a introduction to Rave Reports. Part IJ s7o5s 7o5 to create MasterK8etai* reports using 8irect 8ata Jie5s - #y 2eone* Tognio**i Introduction to Rave Reports - Part IV: More Data Aware Reports In Part III we have explored the data aware capabilities of Rave Reports, using the Driver Data iew! "n Part I we are going to learn how to use Direct Data iews, the creation of #aster$Detail reports, and the use of %alc"P and %alcTotal co&ponents to display calculated values and totals! The Direct Data View The Direct Data iew allows you share the database connection established by your application, fetching data directly fro& the Data'ets in your application! (ou can lin) the& to any TData'et descendant, and, with so&e code, you can even fetch data fro& custo& Data'tructures, li)e arrays of records or T'tringLists! *part fro& that, it behaves in the way as the Driver Data iew we explored on Part III! Using DataSet Connections Let+s create a &aster detail report using Direct Data iews! %reate a new application, and set up a connection with your database using your favorite Db ,ra&ewor)! I+ll still be using BD-, for de&onstration purposes! *dd two tables .or /ueries, as you prefer0, selecting data fro& the orders and ite&s tables! ,or each Data'et, add a corresponding TRvData'et%onnection, available in the Rave tab, in the pallete! 'et the property DataSet of each Data'et%onnection to the corresponding co&ponent, and give the& &eaningful na&es .I called the& dscIte&s and dsc"rders0! The na&e is i&portant: it is the your application lin) to the report! (ou won+t be able to have two Data'et connections, even in different reports, with the sa&e na&e, or you &ight run into trouble if so&eone tries to run both reports concurrently! *fter the Data'ets are set up, return to the Rave Reports designer! %hoose New Data Connection, and you should see the Data'et %onnections you added to your for& in the Delphi designer: P a g e | 11 Introduction to Rave Reports - 2004 'elect dscIte&s to create the first Dataiew, then repeat the process to create the Dataiew for dsc"rders! (ou should now see the fields in the Pro1ect Treeview, under the newly created Dataiews: Don+t forget to rena&e the Dataiews to better na&es than Dataiew2 and Dataiew3! Creating the ands *fter the Dataiews have been created, we should set up the bands! %reate a Region consisting of the whole page area, and add one band .4eader0, two DataBands .#aster and Detail0, and another Band .,ooter0! 'et the Contro!!erand property of 4eader, Detail and ,ooter to #aster! 5sing the andSt"!e property editor, set the style of the 4eader band to od" #eader $%, the style of the Detail band to Detai! $D%, and the ,ooter band to od" &ooter $'%! 6otice how the and Disp!a" gives a nice preview of how the bands are going to printed: (ou also need to lin) the DataView property of the #aster band to dv"rders, and the Detail band to dvIte&s! To create the #aster$Detail relashionship, set the MasterDataView property of the Detail band to dv"rders, and both the Master(e" and Detai!(e" properties to the field "rder6o! The &ontMaster Co)ponent P a g e | 12 Introduction to Rave Reports - 2004 (ou proably want si&ilar ite&s .all the ite&s in the Detail Band, for exa&ple0, to print with the sa&e font! Instead of setting each &ont property individually, you can you a ,ont#aster! *dd a ,ont#aster co&ponent to the page and set its &ont propert to Ti&es 6ew Ro&an, 27! In the next step, when adding the Text and DataText co&ponents, set their &ontMirror property to the ,ont#aster! 6ow, if you ever change your &ind about the font that is going to be used in this report, you don+t need to change it in every co&ponent, 1ust change it in the ,ont#aster and it will be reflect in every other co&ponent that is lin)ed to it! (ou can have as &uch ,ont#asters in one report as you need! The ,ont#aster is a 6on8isual co&ponent, &eaning it won+t show in the Design *rea! If you need to reselect it, you will have to do it through the Pro1ect Treeiew! Adding the DataTe*ts 6ow its 1ust a &atter of adding Text and DataText co&ponents to the bands! Don+t forget you can drag8and8drop .while pressing the ctrl and alt )eys0 fro& the Pro1ect Treeview to create the&! I added "rder6o, 'aleDate, Ter&s, Pay&ent#ethod, *&ountPaid and ,reight to the #aster band, and Ite&6o, Part6o, 9ty and Discount to the Detail band! Don+t forget that the Disp!a"&or)at of float fields is set in the fields the&selves, in the Pro1ect Treeview, and not in the DataText co&ponents! Adding Tota!s and Ca!cu!ated &ie!ds (ou can &a)e calculations and aggregated values using the %alc"P and %alcTotal co&ponents, available on the Report tab! The result of these calculations can be outputted to para&eters, PI ars, or used as inter&ediate result for other calculations! :e are going to output the& to para&eters, so select your report in the Pro1ect Treeview and add two para&eters, called *&ountPaidTotal and ,reightTotal: 6ow add two %alcTotal co&ponents to your the ,ooter band, and set their Contro!!er property to the #aster band, their DataView property to dv"rders, the Data&ie!d to *&ountPaid and ,reight, and the DestPara) to the para&s you created earlier, *&ountPaidTotal and ,reightTotal! It+s also in the %alcTotal co&ponent where you define the Disp!a"&or)at of the value printed! 6ote that the %alc co&ponents are evaluated in the order they appear in the Pro1ect Treeview! If a %alc"p result is going to printed by a DataText co&ponent, &a)e sure it appears in the Treeview before it! (ou can use the buttons #ove ,orward and #ove Behind fro& the *lign&ent Toolbar to change their order! (ou can now add in the ,ooter Band two DataText co&ponents to print those variables! 6otice that is has su&&ed the values, and you can define through the Ca!cT"pe property of the the %alcTotal co&ponents the operation you would li)e to perfor&! The sa&ple data included in the DbDe&os does not have a value for ,reight in any of the records! ,eel free to edit a few records to see the& added up! 6ow let+s suppose we need to su& both totals, and display the& in the footer band! *dd a new para&eter called Total to the report and a %alc"p co&ponent below the %alcTotal co&ponents, in the ,ooter band, and set the Src+Data&ie!d to Para&!*&ountPaidTotal, and Scr,Data&ie!d to Para&!,reightTotal! 'et the DestPara) property to Total, and the Disp!a"&or)at of the value! *dd a DataText to print this value! &inishing Up P a g e | 1: Introduction to Rave Reports - 2004 To add the report to your pro1ect, 1ust do the sa&e as was done in the previous reports: 1ust lin) it in a RvPro1ect and call the execute ðod! (ou &ight want to filter the Data'et based on user input, but that+s the sa&e way as you always done before! Conc!usions :e have seen how to create Data*ware reports using Direct Data iews, how to set up &aster$detail relationships, and how to use %alc co&ponents! (ou can find a pro1ect containing the report developed here on %ode%entral! Part will de&onstrate the use of %usto& %onnections and so&e other tric)s!
Chatlog 2-22-14 To 4 - 27 - 14 - Weekend Performance Tuning - Analyzing With DBA Skillsets - Every Sat - Sun 10 - 00 Am To 5 - 00 PM 2014-04-19 13 - 58