Mega Code Archive

 
Categories / Delphi / Examples
 

Separating EkRtf data from applications

Title: Separating EkRtf data from applications Question: Eugene Kuchugurov has done a great job providing Delphi developer with EkRtf which enables separation between report template and application. The advantages of this separation is when the needs for customizing reports arises, we just edit the template and voila your report has new look without altering Delphi codes. But if the data needed for new report are not passed to EkRtf then we have to alter our Delphi codes. I have built a small application for doing reporting using data from BDE and generating report using EkRtf. Answer: EkRtf is a mature reporting component. I have tried so many complex reporting situation using this component. My latest delightful experience with EkRtf are user defined function (UDF) and constant expression for UDF. These two babies allow me filtering dataset inside my report template. So if you need something just develop your own UDF and you can use it from your report template. OK I think I have enough words to introduce you to EkRtf. Now we're talkin about my small reporting application. This application is very simple and straightforward. First you must define BDE TDatabase.Parameters value. You can define a BDE alias or configure each parameters yourself. This connection information can be stored to a .DTB file or read from a .DTB file. After you have setup database connection you will be connected to a database through BDE. The next step is defining queries and the parameters that will be used for reporting. This queries and parameters information can be stored to a .QRY file or read from a .QRY file. Why should i separate database connection file from queries and parameters file? I separate them since in one database connection there can be multiple report data. My application can setup master detail relationship between your queries. There are two ways my application will recognize the need for setting up master detail between two queries. First, detail parameter-names to master field-names matching. When there is a match with previous query then it will become a master dataset. Second, detail dataset name to master dataset name matching. The master dataset name must be a prefix of detail dataset name. For example: qry11 is a detail dataset of qry1. Since the nature of BDE the second way can be neglected. But it's a good naming convention so you can see the relationship just from their name. The next step is defining the types and the values of parameters that are not relationship parameter. Or in other words, information about parameters of datasets that don't have a master dataset. You can enter value to a parameter simply by double clicking the listbox item. After all datasets are loaded you can continue by defining your report RTF output and your report RTF template or input. Now you're ready for generating a report. I'll send the project files to delphi3000 admins, so please be patient.