Vous êtes sur la page 1sur 3

Demo 1 First define dataset. Edit/Datasets click add. Set name to players, define connection string by clicking Define.

Choose Microsoft Jet OLE DB Provide r and click next. Browse to the db1.mdb and click OK. Into SQL insert SELECT * FROM PLAYERS. You can also insert SELECT * FROM and then right click on the edit field and select Insert table from the popup menu. Select the right table from the list and click OK. Now click Test and you shoud be prompted that everything is ok. Click OK and then Close on the datasets window. Now you are ready to design report. Select dsrBand from components toolbar and drop it on the report. Select dsrLabel and drop it on the first band. Set caption of that label to PLAYERS. Select another dsrBand and drop it under the first band. Set it's Dataset property to players and BandType to btLoop. Select dsrDBText from components toolbar and drop it on the second band. Set property DataField by clicking ellipsis button. Select field NAME from table players. DataField property should be set to NAME and Dataset property to players. Save report as demo01. Now click preview. All players in the table should be listed. Now define another dataset. Name it TeamsLookup, set SQL to SELECT * FROM TEAMS. Select dsrExprLabel and drop it on the second band. Set Expression property to LOOKUP function. Insert in place lookup table 'TeamsLookup' in place of lookup key field insert 'ID', in place of lookup result field insert 'NAME' and in place of lookup key value insert [players.team]. Preview report. As you can see you defined lookup field to get name of the team for each user out. Demo 2 Take demo01 and save it as demo02. Edit dataset players and set SQL to SELECT * FROM PLAYERS ORDER BY TEAM. Preview report. Now lets say you want to group players of one team to one page. We will use group band. Select dsrDBText1 and dsrExprLabel1 on the second band and cut them. Set second band height to something more and BandType to GroupBase. Select dsrBand and drop two bands on the second band. Now paste those two controls on that fourth band. Now cut dsrExpr from fourth band and paste it on the third band. Select band3 and set BandType to btGroup and set GroupExpr to [players.TEAM] and Dataset to players. Preview. This is how grouping is done. Now set the BreakPage of the band2 to true. Now you get every team on it's own page. Demo 3 Take demo02 and save it as demo03. Put another band on the band2 under band4. Drop dsrExprLabel on it. Set Expression to AVERAGE([players.HEIGHT]) and set property ResetAfterPrint to true. Also drop another dsrDBText near NAME and set DataField to HEIGHT. You have average team height info there. Demo 4 Take demo01 and save it as demo04. Edit variables and add variable team with value 1. Edit players dataset and set SQL to SELECT * FROM PLAYERS WHERE TEAM = :team ORDER BY HEIGHT. Preview. As you can see pretty report asks you to insert the team you want to view. Demo 5 Take demo04 and save it as demo05. Go Edit/Input form. New designer is brought

up where you can design input form for variables. Drop edit on the form. Set ButtonVisible to true, set LookupTable to TeamsLookup, LookupKeyField to id and LookupResultField to Name. Set Variable property to team. Drop label on the form and set LookupLabel property of edit to that label. Press save and close. Now preview. New input form is there. Press on Button near edit. Teams table should popup. Go into the name column and press m. See how filtering works. To delete filter press backspace or Ctrl+backspace. After you selected the right team press Enter. See how label's caption is set to the right team name. Now press OK and players of that team should be on the report. Demo 6 For this demo you don't need to design anything. It shows you how to generate reports into pdf file. Purpose of this is to generate reports over the night for example so that reports are waiting for you in the morning when you get in your office. Or you can call to generate reports from the web application and after that show that report to the users over the internet. Type this into command line: PRETTYREPORTSDIR\PrettyReports.exe /pdf=c:\1.pdf /pr=DEMOSDIR\demo04.pr /var:tea m=4 where PRETTYREPORTSDIR means folder where PrettyReports.exe is located and DEMOSDIR means folder where your demo04.pr is located. After you run this, you should get 1.pdf on the root of your C: and report should be for players in team 4 meaning San Antonio Spurs. Demo 7 Take demo01 and save it as demo07. Click Edit, Memory Tables, then Add. Set name as group, define two fields. Field with name team, data type String and size 2. Field with name players, data type Integer and size 3. Drop another band at the bottom of the report. Set Dataset to group and BandType to btLoop. Drop two DBTexts on that band and set their Dataset and DataField properties to group, team, players. Select Band2 and double click on OnPrint property. You should get into code window, everything should be already prepared for you. Code should look like this: procedure dsrBand2OnPrint; begin if group.Locate('team', [players.Value('team')]) then begin group.Edit; group.SetValue('players', group.Value('players') + 1); end else begin group.Insert; group.SetValue('team', players.Value('team')); group.SetValue('players', 1); end; group.Post; group.First; end; begin end. Now run the preview. At the end of report you should see how many players each team has. Team 2 has 3, team 3 has 2 and team 4 has 3. This memory tables can be used to group data or for anything else and then print that at some stage.

Note that you can put breakpoint in the code, step over and step into code. Code editor also has completion proposal. Press Ctrl+Space to activate it. It is possible to evaluate certain expressions as well. Other demos: If you have BDE installed (Borland database engine) you can check bde01. With Pretty Reports you can connect to various databases. If you have appropriate databse installed you can also check ib01, mysql01, vistadb01. Also check sqlite. SQLite is free database. Also check txt01 and see how you can connect to txt files. Also check how you can connect to Excel in demo excel01. This connection is made trough ADO as connections to mdb. If you have BDE installed you can also check bde02. See how pictures from database can be handled. Check rich01, rich02 and rich03 to see how rtf can be printed. Check sidepage to see how side page works. Check script01, script02 and script03 to see script in work. Check picture01 to see how pictures are handled. Check memtest01 to see how memory tables can be handled. Check memo01 and memo02 to see how memos work. Check masterdetail01, masterdetail02 and masterdetail with frames to see how master detail works and to see how frames work. With frames you can do a lot of interesting things. Check graph01, graph02 and graph03 to see how to work with graphs. Check expr01 and expr02 to see expression in work.

Vous aimerez peut-être aussi