Download presentation
Presentation is loading. Please wait.
Published byBrandon Edwards Modified over 9 years ago
1
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-9, 2005 Key Biscayne, Florida Using the Crystal RDC Interface in Visual DataFlex John J Tuohy Data Access Worldwide
2
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida What does the Crystal class do? Allows you to run a Crystal Report from within your VDF Application At the most basic level you want to select a report and run it Just select a Report, select an output destination and run it In more advanced cases you want to dynamically change the report at runtime Change the sort order Change record and group selection formulas Change formula and parameter values Change tables being used in a report Generate and use dynamic (non-table based) data
3
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida How the current Crystal class works CrystalReport class Based on crpe32.dll API Can be distributed royalty free Implemented using VDF’s External_functions Uses a flat Interface which passes complex data Works great
4
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Why do we need to change this? Business Objects / Crystal really wants you to stop using it! As of Crystal Reports XI It is no longer supported Crystal XI claims it’s not even there (it is) It is very old technology that will not be updated or fixed It has been replaced with their RDC API
5
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida How does the new interface work? Based on their Report Design Component (RDC) API RDC is a COM interface Imported via FlexCom2 Uses Craxddrt.dll – automation library CRViewer.dll – activeX Report viewer CDO32.dll – automation library Can be distributed royalty free Uses the RDC object model Lots of objects with simple interfaces
6
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Implementation plans Provide a new class, cCrystal, which will wrap all of the RDC COM objects Make it easy to get at the most commonly needed COM objects Simplify the object aggregation process Use the standard RDC object model and interface Provide a simple way to view reports within an application Provide helper interfaces to make it easy to do the most commonly required tasks For more complicated tasks, provide good samples to show how to do it. Get out of the way!
7
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida What are the benefits of using the new class? You are up to date You have more features at your disposal (e.g. CDO) You are using the industry standard method for working with Crystal This lets you use the Crystal Documentation, Crystal Newsgroups, etc. to get development assistance. Once you “get it”, it's not that hard The skills you learn can be applied to other COM solutions
8
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Compatibility issues The new class is not designed to be compatible with the old class You can still use CRPE32 for your old reports Options we are considering for providing a “compatibility layer” None at all Could provide a limited compatibility layer Could provide a complete compatibility layer Give us your feedback on this issue.
9
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida The new class structure/interface cCrystal class Property Integer peOutputDestination Property String psReportName Procedure RunReport Procedure OnInitializeReport handle hoReport Procedure PrintReport handle hoReport Procedure PreviewReport handle hoReport Procedure ExportReport handle hoReport
10
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Samples: Print to viewer // // Simple Print (default is print to preview) // Object oCrystalReport is a cCrystal Set psReportName to "CustLst.rpt" End_Object
11
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Samples: Select output destination Object oCrystalReport is a cCrystal Set psReportName to "CustLst.rpt" End_Object Object oPrintToScreen is a Button Procedure OnClick Set peOutputDestination of oCrystalReport to PRINT_TO_WINDOW Send RunReport of oCrystalReport End_Procedure End_Object Object oPrintToExport is a Button Procedure OnClick Set peOutputDestination of oCrystalReport to PRINT_TO_FILE Send RunReport of oCrystalReport End_Procedure End_Object
12
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Samples: Select printer via prompt Object oCrystalReport is a cCrystal Set psReportName to "CustLst.rpt" Procedure OnInitializeReport Handle hoReport Forward Send OnInitializeReport hoReport End_Procedure Procedure PrintReport handle hoReport Set piPrinterPrompt of hoReport to True End_Procedure End_Object Object oButton1 is a Button Procedure OnClick Set peOutputDestination of oCrystalReport to PRINT_TO_PRINTER Send RunReport of oCrystalReport End_Procedure End_Object
13
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Samples: Output to predefined printer Object oCrystalReport is a cCrystal Set psReportName to "CustLst.rpt" Set peOutputDestination of oCrystalReport to PRINT_TO_PRINTER Procedure OnInitializeReport Handle hoReport Forward Send OnInitializeReport hoReport End_Procedure Procedure PrintReport Handle hoReport Send ComSelectPrinterof hoReport "winspool" "Lexmark 3320" "LPT1:" Set ComPaperOrientationof hoReport to crLandscape Set ComPaperSizeof hoReport to crPaperLetter Set piPrinterCopiesof hoReport to 2 Set pbPrinterCollateof hoReport to FALSE Forward Send PrintReport hoReport End_Procedure End_Object
14
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Samples: Output to MAPI – no prompt Object oCrystalReport is a cCrystal Set psReportName to "CustLst.rpt" Set peDestination to Print_to_File Procedure ExportReport Handle hoReport Handle hoExport Get ExportObject of hoReport to hoExport Set pbPromptExportof hoReport to False Set ComDestinationTypeof hoExport to crEDTEMailMAPI Set ComMailToListof hoExport to "someoneelse@hotmail.com" Set ComMailSubjectof hoExport to "Testing" Set ComMailMessageof hoExport to "This is a test" Set ComExportFileNameof hoExport to "MyReport.pdf" Set ComFormatTypeof hoExport to crEFTPortableDocFormat Forward Send ExportReport hoReport End_Procedure End_Object
15
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Samples: Assign selections, formulas and sorts Object oCrystalReport is a cCrystal Set psReportName to "CustLst.rpt" Procedure OnInitializeReport Handle hoReport : // set record selection formula Get Value of oForm1 to sState Set ComRecordSelectionFormula of hoReport to ('{Cust.State}="' * sState * '"}') // set a formula Send AssignFormula of hoReport "Company Name" '"Data Access Corporation"' // assign a sort order Send DeleteSortOrder of hoReport Send AppendSortField of hoReport "Cust" "State" crAscendingOrder Send AppendSortField of hoReport "Cust" "Name" crDescendingOrder End_Procedure End_Object
16
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Samples: Using CDO (dynamic data sources) Object oReport is a cCrystal Set psReportName To "PercentageFilled.rpt" Procedure OnInitializeReport Handle hoReport Handle hoCDO Integer iItem Variant[][3] vData Forward Send OnInitializeReport hoReport Get CreateCDO of hoReport "Stuff.ttx" to hoCDO If hoCDO begin Direct_input "c:MyListOfStuf" While (not(SeqEof)) Readln vData[iItem][0], vData[iItem][1], vData[iItem][2] Increment iItem End // Add rows to CDO object Send ComAddRows of hoCDO vData End End_Procedure // OnInitializeReport End_Object // oReport
17
Open Solutions for a Changing World™ Copyright 2005, Data Access Worldwide June 6-8,2005 Key Biscayne, Florida Samples: Using CDO with Code Validation Tables Object oReport is a cCrystal Set psReportName To "PercentageFilled.rpt" Procedure OnInitializeReport Handle hoReport Handle hoCDO Variant[][2] vData Forward Send OnInitializeReport hoReport Get CreateCDO of hoReport "States.ttx" to hoCDO Get TableData of Customer_State_VT to vData Send ComAddRows of hoCDO vData End_Procedure // OnInitializeReport End_Object // oReport
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.