Sunteți pe pagina 1din 4

Using Automation with Crystal Reports and Delphi Previewing reports using the CRViewer ActiveX control Product:

Delphi 4. !or higher" Category: Reporting #$ill %evel: #coring: %ast Update: &'(&4()&&* #earch +eys: delphi delphi,&&& article -orland vcl code.snippet Crystal Reports Report Reporting #eagate Crystal Descisions Automation RDC CRViewer ActiveX /imes #cored: )0 Visits: ,&)14 Uploader: 2e33 4uidotti Company: Re3erence: Crystal Decisions . Crystal Reports . 5e- #ite 6uestion(Pro-lem(A-stract: /his article should help you get started using the automation 3eatures o3 Crystal Reports 7.&8 in Delphi. Answer:

9n order to use the automation 3eatures in Crystal Reports 7.& and higher: you must 3irst import the type li-raries into Delphi. *. ;rom the Delphi 9D< main menu: go to Pro=ect > 9mport /ype %i-ary. ). ?ighlight @Crystal Report 7 Active X Designer Run /ime %i-ary@. ,. 9n the Class Aames -o : change the 3ollowing items !/Report and /Data-ase con3lict with standard Delphi components": /Report BBB change to BBB /CrReport /Data-ase BBB change to BBB /CrData-ase 4. Change the Palette page to Crystal Reports '. Clic$ @4enerate Component 5rapper@ C. Clic$ @9nstall...@ 1. Clic$ the 9nto Aew Pac$age ta-. 7. Clic$ @Drowse@: select a destination directory 3or the new pac$age: enter. the 3ilename @CREAU/F.DP+@: then clic$ the @Fpen@ -utton. 0. <nter the description @Crystal Reports Automation #erver@ !or another one i3 you li$e": and clic$ the @F+@ -utton. *&. At the con3irmation -o @Pac$age CREAU/F.-pl will -e -uilt then installed. ContinueG@ choose @Ao@. **. 4o -ac$ to the main menu and choose Pro=ect > 9mport /ype %i-rary. *). /his time choose the @Crystal Report Viewer Control@. *,. Change the Palette page to Crystal Reports *4. Clic$ @4enerate Component 5rapper@

*'. Clic$ @9nstall...@ *C. Clic$ the 9nto < isting Pac$age ta-. *1. Drowse or #elect the @CREAU/F.DP+@ pac$age we created earlier. *7. Clic$ @F+@ *0. /his time the install con3irmation -o : clic$ @Hes@. )&. A message will appear noti3ying you that the 3ollowing components have -een registered: /Application: /CR;ield: /CR;ields: /CrReport: CRV<vent9n3o: /CRViewer: /CRV/rac$Cursor9n3o: /Report#ourceRouter. Clic$ @F+@ )*. #ave and Close the pac$age. )). 5e have now imported the appropriate type li-raries and are ready to -uild a test application. AF/<: 9mporting the Crystal Report Run /ime %i-rary registers a component /Application. /his will con3lict with /Application . the Delphi standard component. 93 you need to access the original /Application in a 3orm where you are using the Crystal Reports #erver components or Crystal Reports viewer: you can access it as: ;orms.Application. ............................................................................... Ae t you must create a sample report in Crystal Reports to wor$ with. ;or purposes o3 this e ample: ma$e a very simple report =ust until you are com3orta-le with the process: then e pand on it 3rom there. #ave this report to @C:IJyReport.rpt@. ............................................................................... Ae t let@s setup the sample application: *. 9n Delphi: create a Aew Application. ). ;rom the Crystal Reports ta- drop an Application component onto the 3orm and rename it @CrystalApp@. ,. Ae t drop a CrReport component onto the 3orm and rename it @CrystalRpt@. 4. ;inally drop a CRViewer component onto the 3orm: rename it @CrystalView@: and change the align pro-a-ly to alClient. '. 9n the ;ormCreate procedure 3or the 3orm: enter the 3ollowing: CrystalApp.%ogFn#erver!"K L MMMMMMMMMMM #<< AF/<# D<%F5 N CrystalRpt.Connect/o!CrystalApp.FpenReport!@C:IJyReport.rpt@""K CrystalView.Report#ource :O CrystalReport.De3ault9nter3aceK CrystalView.ViewReportK /he CrystalApp.%ogFn#erver call can ta$e a wide variety o3 input depending

on how you are connecting to the data-ase used in your report. /he 3ollowing is an e cerpt 3rom Crystal Reports Developer ?elp ;ile: #ynta ...... %ogFn#erver ! pDllAame As #tring: p#erverAame As #tring: PpData-aseAameQ: PpUser9DQ: PpPasswordQ " Parameters Description .......... ............................................................ pDllAame #peci3ies the name o3 the D%% 3or the server or password protected non.#6% ta-le you want to log on to: 3or e ample RPD#FDDC.D%%R. Aote that the dllAame must -e enclosed in Suotes. D%% names have the 3ollowing naming convention: PDDT.D%% 3or standard !non.#6%" data-ases: PD#T.D%% 3or #6%(FDDC data-ases. #peci3ies the name o3 the D%% 3or the server or password protected non.#6% ta-le you want to log on to: 3or e ample RPD#FDDC.D%%R. Aote that the dllAame must -e enclosed in Suotes. D%% names have the 3ollowing naming convention: PDDT.D%% 3or standard !non.#6%"data-ases: PD#T.D%% 3or #6%(FDDC data-ases. p#erverAame #peci3ies the log on name 3or the server used to create the report. ;or FDDC: use the data source name. /his value is case.sensitive. #ee Remar$s -elow. PpData-aseAameQ #peci3ies the name 3or the data-ase used to create the report. #ee Remar$s -elow. PpUser9DQ #peci3ies the User 9D num-er necessary to log on to the server. #ee Remar$s -elow. #peci3ies the password necessary to log on to the server.

PpPasswordQ

Remar$s ....... 5hen you pass an empty string !RR" 3or this parameter: the program uses the value that@s already set in the report. 93 you want to override a value that@s already set in the report: use a non.empty string !3or e ample: R#erver AR". AF/<: ;or an easy way to determine what your correct %ogFn#erver server is: open the report in Crystal Reports: and 3rom the main menu go to Data-ase > #et

%ocation. /he location screen will show you the settings 3or #erver /ype: #erver Aame: Data-ase: and User 9D. AF/<: ;or an easy way to determine the correct dllAame to use: open the report in Crystal Reports: and 3rom the main menu go to Data-ase > Convert Data-ase Driver. ;rom the Convert Data-ase Driver window: place a chec$mar$ in the -o @Convert Data-ase Driver on ne t Re3resh@. Hour dllAame is listed ne t to ;rom. C%9C+ CAAC<% 5?<A C%F#9A4 /?9# 59ADF5 #F HFU DF AF/ AC/UA%%H C?AA4< /?< DA/ADA#< DR9V<RU 9 connect to a password protected Jicroso3t Access 01 data-ase and use the 3ollowing 3ormat. %ogFn#erver!@pdsod-c.dll@:@JyD#A.dsn@:@@:@DDEUsername@:@DDEPassword@"K AF/<: ;or those un3amiliar with FDDC: the D#A is setup through FDDC Data #ources in 5indows Control Panel: and contains the data-ase type: location: system data-ase: and additional logon in3o. Hou may have to e periment around a -it to get the %ogFn#erver 3unciton wor$ing 3or your connectivity needs. Re3erence the help 3ile Developr.hlp in the #eagate #o3tware directory 3or assistance. /hat@s A%% there is to itU

S-ar putea să vă placă și