DataFlex Reports
Developer Guide Integrate DataFlex Reports in your DataFlex Applications
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 2 of 247 z
Business Software for a Changing WorldTM
Please forward all your findings (suggestions, bugs in the documentation) to [email protected].
Technical support:
Internet: http://www.dataaccess.com
Forums: http://support.dataaccess.com/forums
E-mail: [email protected]
Revision Date: December, 2014
DataFlex Reports Developer
Guide
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 3 of 247 z
Business Software for a Changing WorldTM
COPYRIGHT NOTICE
© 2009-2014 DATA ACCESS CORPORATION. All rights reserved.
No part of this publication may be copied or distributed, transmitted, transcribed, stored in a retrieval system,
or translated into any human or computer language, in any form or by any means, electronic, mechanical,
magnetic, manual, or otherwise, or disclosed to third parties without the express written permission of Data
Access Corporation, Miami, Florida, USA.
DISCLAIMER
Data Access Corporation makes no representation or warranties express or implied, with respect to this
publication, or any Data Access Corporation product, including but not limited to warranties of merchantability
or fitness for any particular purpose.
Data Access Corporation reserves to itself the right to make changes, enhancements, revisions and alterations of
any kind to this publication or the product(s) it covers without obligation to notify any person, institution or
organization of such changes, enhancements, revisions and alterations.
TRADEMARKS
DataFlex is a trademark of Data Access Corporation.
DB2 is a registered trademark of IBM Corporation.
Pervasive.SQL is a registered trademark of Pervasive Software, Inc.
Windows Server 2008, Windows Server 2003, Windows 7, Windows Vista, Windows XP, Windows ME, Windows
2000 and Windows 98 are registered trademarks of Microsoft Corporation.
All other company, brand, and product names are registered trademarks or trademarks of their respective
holders.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 4 of 247 z
Business Software for a Changing WorldTM
Table of Contents
1. Welcome to DataFlex Reports! ........................................................................... 5
2. Application Integration ....................................................................................... 6
2.1 Adding the DataFlex Reports Library to a Workspace ............................................................. 6
2.2 Getting started with the Integration Wizard ........................................................................... 7
2.3 DataFlex Reports Application Programming Interface .......................................................... 21
2.4 cDRReport class ....................................................................................................................... 23
2.5 cDRSortColumnsGrid class .................................................................................................... 167
2.6 cDRSortDirectionsGridColumn class .................................................................................... 173
2.7 cDRMenuItem class ............................................................................................................... 179
2.8 cDRExportMenuItem class .................................................................................................... 183
2.9 cDRPreview class ................................................................................................................... 184
2.10 cDRPreviewWindow class ................................................................................................... 192
2.11 cDRToolPanelPreview class ................................................................................................ 193
2.12 cDRWebSortColumnsGrid class .......................................................................................... 201
2.13 cDRWebSortDirectionColumn class ................................................................................... 206
2.14 cWebDRReportViewer class ............................................................................................... 211
2.15 Templates ............................................................................................................................ 231
2.16 Printing ................................................................................................................................. 234
2.17 Constants ............................................................................................................................. 235
2.18 Structs .................................................................................................................................. 239
3. Deploying the DataFlex Reports Developer Edition Runtime .......................... 242
4. Product support ............................................................................................. 243
Index .................................................................................................................. 244
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 5 of 247 z
Business Software for a Changing WorldTM
1. Welcome to DataFlex Reports!
DataFlex Reports is a software tool for delivering timely, well organized reports and information to the people
who need it.
Designed to be used by end-users, power-users and professional software developers alike, DataFlex Reports
works with a wide variety of ODBC data sources including – but not limited to – Microsoft SQL Server, IBM DB2,
Oracle, MySQL, Pervasive SQL, PostgreSQL, Microsoft Access, the DataFlex embedded database and more.
DataFlex Reports’ Report Creation Wizard steps users through the entire process of creating a report from
selecting data sources to grouping, filtering, summarizing and sorting information. The wizard displays the
completed report in a visual, drag & drop WYSIWYG interface. Ready to view the results on-screen, print or make
further formatting changes and enhancements. A full range of text formatting (fonts, bold, italics, justification,
etc.) is available in DataFlex Reports along with a rich library of string, logical and math functions.
DataFlex Reports is developed in DataFlex, the state-of-art software development tool from Data Access
Worldwide.
For DataFlex developers, DataFlex Reports offers both seamless integration with their DataFlex development
environment and seamless integration of reports in Windows applications. When DataFlex Reports is installed
with DataFlex, a report integration wizard is automatically provided in the Studio.
For deployment, reports integrated in DataFlex Windows applications require only the installation of a single
OCX. Distribution of integrated reports and the OCX is royalty-free with the Developer Edition of DataFlex
Reports.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 6 of 247 z
Business Software for a Changing WorldTM
2. Application Integration
An Application Programming Interface (API) for DataFlex Studio is available. When DataFlex Reports is installed
on a computer, if an appropriate version of DataFlex Studio is already present, this API can be optionally selected
for automatic installation along with DataFlex Reports itself.
For the integration of DataFlex Reports in the DataFlex development environment a library workspace is installed
and a new wizard becomes available in the DataFlex Studio performing the following steps:
• Selection of the report to be integrated in the current workspace and project.
• Defining the criteria on which the end-user will be able to filter data when running the report.
• Defining the sort order of the report.
• Defining the Output Destinations that the end-user eventually can select.
• Generating a Report View in the Studio.
2.1 Adding the DataFlex Reports Library to a Workspace In order to be able to use integrated reports in a DataFlex workspace the
DataFlex Reports library must be added to that workspace.
Select the ‘Maintain Libraries’ option from the ‘Tools’ menu to add the DataFlex
Reports library to the current workspace. Browse to the location of the DataFlex
Reports library after clicking the ‘Add Library’ button in the Library Maintenance
dialog that opens. In the library folder select the SWS file.
During the installation of DataFlex
Reports one or more library versions
could be installed. Depending on the
installed DataFlex version a library can be
installed or not. Browse to the library
folder that matches with the DataFlex
product currently used. Select the SWS
file from the folder.
Click the ‘OK’ button to connect the
library to the workspace. A wizard will be
started to guide through the attach library process.
On the first wizard page (after the usual welcome page) a choice can be made to attempt to update the
templates.xml file in the DataFlex Reports library. This feature is only needed if the DataFlex Reports library was
moved from the folder selected during the installation process of DataFlex Reports.
The content of the second page of the wizard depends on the current DataFlex product. If version 17.1 or later is
used the page contains options regarding web application integration. The contents of the library
AppHtml\DataFlexReports folder need to be copied to the workspace if a web application is developed and
integration is desired. This action can be skipped if a Windows application is being developed in the workspace.
If a web application is developed the contents need to be copied and the CSS file for DataFlex Reports need to
be loaded. One of the ways to do this is via including in the application.css file. The wizard will disable the
option of including if no application.css file can be found. If a web application is being developed the
JavaScript class for previewing DataFlex Reports documents need to be loaded. The wizard looks for a file named
index.html (default for DataFlex web applications) and offer to update this file. Deselect update
application.css and/or index.html if a manual action is desired.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 7 of 247 z
Business Software for a Changing WorldTM
Starting with DataFlex 17.1 a folder named Reports as sibling of AppSrc and AppHtml will be the suggested
folder for reports in a workspace. Reports used in a web application need to store the output in a folder which is
not directly accessible from the web browser. The suggested name is Cache to be created inside the Reports
folder. The wizard can create these folders.
All wizard activities can be logged in a text file. Used the contents of this log file to resolve problems (if any).
2.2 Getting started with the Integration Wizard The library comes with a wizard that can write Windows or Web application components. The wizard operates
different based on the current selected project (which is a web or a Windows type of application). First the
Windows application integration is explained followed by Web application integration.
2.2.1 Report integration for Windows applications To start the wizard, go to the File menu and choose the ‘New’ option, followed by the ‘View / Report’ option.
The dialog to select from looks like:
For the explanation of the wizard that follows it is assumed that:
• The ‘Order Entry’ workspace is selected.
• The DataFlex Reports library is added to that workspace.
• A simple report, named CustomerList.dr, was created with DataFlex Reports in the Reports folder
showing customer data. A report with this name is present in the WebOrder example folder and can be
copied to the Reports folder of the ‘Order Entry’ workspace to bypass the requirement of creating one.
• The Windows project (Orders.src) is selected in the workspace.
The first window explains the function of the wizard. Click ‘Next’ to proceed.
On the next page select the report named CustomerList.dr. The wizard looks in a folder Reports but the
browse button can be used to select a report from another folder. Selecting a report from another folder has
impact on the functionality of the wizard and the integration library. Selection list usage will not be made
available for reports from a folder outside the workspace. If the report is based on tables of the DataFlex
embedded database paths to the database or individual tables can be automatically corrected to the workspace
paths. Select the checkbox “Auto correct DataFlex table paths to workspace paths” if this is desired. It should not
be selected if report contains tables that are not present in the workspace without developer coding. In such a
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 8 of 247 z
Business Software for a Changing WorldTM
case it might be needed to write own code to connect report to data. If the data is retrieved from an ODBC or
RDS data-source this option has no meaning. The preview button can be used to preview the report to discover
if the correct report was selected. Running a report without selection criteria might take a while and previewing
should not be chosen.
It is not possible to continue if the report was
not created with the same version of the
installed DataFlex Reports OCX. An error as
shown here will be presented.
In such a case the report needs to be opened in
the DataFlex Reports designer and saved to disk.
In the next wizard page –
titled ‘Names’ – the
component object name, the
file name and description to
be used for the menu item
creation can be entered. If
the object name does not
start with an ‘o’ the wizard
suggests to change the name.
The wizard creates names
based on the name of the
chosen report. In the picture
the name
‘oCustomerListReportView’ is
shown as the object name
because the name of the
selected report was
CustomerList.dr. The object
name needs be unique within
the current project. The wizard will generate a ReportView based object that will be used to address the module.
Press the Next button again for the next wizard page in which columns can be selected that allow the end-user
to specify selection criteria.
The columns ‘Customer_Number’ and ‘Customer_City’ are shown as selected columns. If the end-user enters
values in the input controls the data will be filtered on these values. Two input controls will be created for all
selected columns to make a range selection possible. All code generated by the wizard can be modified.
The order of the input controls can be changed via right mouse click as shown in
the image.
Note: The wizard will automatically create a connection to a selection list
component if the workspace contains a data dictionary class for the table of the selected columns. A drop-down
(comboform) control will be created if the data dictionary contains a validation table for the selected columns. If
no data dictionary can be found or if the report uses ODBC or RDS data this feature cannot be offered and the
developer would need to write own coding.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 9 of 247 z
Business Software for a Changing WorldTM
The next wizard page depends
on the report definition. If the
report contains a filter (expert
and/or filter function) the next
wizard page(s) show the
filters. Editing of the filter is
not possible; selecting to keep
or remove the filters can be
done via the radios below the
grid.
Keeping the filter definitions
results in a report that filters
the data on the predefined
filter plus the values from the
selection input controls.
The next wizard page again
depends on the report
definition. If the report
contains parameters, the
CustomerList.dr does not contain parameters, a page will be shown in which parameters can be selected for
which an input control will be created. A checkbox below the list of parameters make it possible to ask the
wizard to generate source code for the parameters that were not selected. Via source code these parameters
can be given a value. The reference further in this guide handles the parameter usage.
An input control will be
generated for each of the
selection and or parameter
fields.
The generated label for the
input control can be changed
in the labels and alignment
wizard page.
On the same wizard page the
label justification mode can be
chosen by clicking the
corresponding radio in the
‘Justification’ group.
Finally it is possible to set the
peAnchors property of the
input controls by selecting
‘left-right’ or ‘none’ from the
combo-form control. The
width of the input controls will change if ‘left-right’ is chosen and the report view component gets more or less
wide.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 10 of 247 z
Business Software for a Changing WorldTM
After clicking Next the wizard
makes it possible to set the
sort order of the data
displayed in the details section
of the report.
The wizard shows the record
sort order defined in the
report if any.
With a right mouse click the
sort direction (ascending or
descending) can be selected
per column. The floating
menu also makes the sort
order change-able.
With the checkboxes
underneath the selected sort
columns list it is possible to
indicate that code needs to be
written that allows the user to change the sort order and if this is a single sort order or a multi column sort
order.
The next wizard page makes it possible to decide what preview style to be used if ‘preview report’ is chosen.
If the report results should be
sent to a printer or export the
preview style cannot be
chosen and running the report
results in the output being
sent to a printer or exported
to a file.
The preview styles supported
are:
• Modal dialog
• MDI view
• Embedded
• Toolpanel
Modal preview of the results
need to be closed before
further interaction with the
application can be done.
An MDI view preview style
interface dynamically creates a view object (MDI child window) in the application’s client area, displaying the
report results.
Choose for ‘Embedded in report view’ if results and selection criteria needs to be placed on the same view. The
wizard generates a report view with two tab-pages, one for the selection criteria and one for the results.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 11 of 247 z
Business Software for a Changing WorldTM
The fourth option, toolpanel, is a mix between a modal dialog and an MDI view. The results window pops out
(comparable to a modal dialog) of the program but navigation to other parts of the application are possible (like
an MDI view).
The checkbox for prompt list support can be ticked if creation of selection criteria controls is selected earlier in
the wizard process and prompt list support can be made available by the wizard. The DataFlex framework
supports two kinds of selection lists; the wizard cannot know what selection lists are currently in use or will be
used in the (near) future. Knowledge of the workspace contents is necessary to make a correct decision.
The next step in the process
concerns the enclosure of
bitmaps and icons.
The library contains a number
of images used in a toolbar
and in dialogs. The images
need to be distributed with
the application as external
files or they can be embedded
in the compiled project. The
DataFlex compiler embeds the
images listed in the
.cfg file in
the compiled executable.
A workspace may contain
several projects. Not all
projects might need a
connection to DataFlex
Reports. Select the projects
for which the library bitmaps and icons need to be added to a project’s CFG file. Make sure the project’s CFG
file(s) is/are writeable.
The next step in the wizard is
valid for Windows or Web
projects with DataFlex Reports
integration. By choosing a
language the print engine
translates language items
such as Page N of M into the
chosen language.
Sorting inside DataFlex
Reports uses a collating
sequence which is maintained
in a file. By default the
DataFlex development
collating sequence file
(df_collate.cfg in the bin
folder) is copied to the
DataFlex Reports design
environment during
installation. The integration
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 12 of 247 z
Business Software for a Changing WorldTM
might need to use a different collating sequence to that of the application and this can be done by specifying the
path to and the name of the file with the (different) collating sequence information.
If the report is based on an ODBC data-source the third option can be selected which generates code in the
report object in which a change in the data-source can be programmed.
The next step in the wizard
depends again on the report.
If the report or one of the
sub-reports contains user
defined functions the wizard
shows these functions.
Each of the functions can be
inspected and selected for
code generation. Functions
that are designed to have a
different value than entered
during report creation can be
changed via source code.
After all your choices have
been made we can finish the
creation of the ReportView
module by clicking the ‘Finish’
button. The wizard will close
and generates a Report View component.
The generated Report View is now available in DataFlex Studio.
Notice the prompt buttons and the drop-down controls for the selection
of ‘Customer Number’ and ‘State’. These are available because the data
dictionary class for the customer table in this workspace defines a
selection list and a code validation table.
The controls are not data-aware, the view does not contain data
dictionary objects, browsing for a customer is not possible if not using
the selection list.
Once the Report View is created in DataFlex Studio, everything is based
on source-code. Double-clicking on the View (or toggling to source view
by pressing the F7-key) shows the source-code.
The layout or position of any visual object in the ReportView component
can be altered within the DataFlex Studio designer.
It is worth taking a closer look at procedures – e.g. ‘OnInitializeReport’ &
‘SetFilters’ – created by the wizard. For example the ‘SetFilters’ method
which defines the report filter based on the user input.
The DataFlex Reports print engine object is visible as a small square in the
top left corner of the report view. This should not be made smaller as a
size of 2x2 is needed to get the preview working correctly.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 13 of 247 z
Business Software for a Changing WorldTM
Simply pressing the F5 key will compile and run the application. The end-user can now easily make selections,
set the sort order and then preview, print or export the report results.
The report view does not need to have input controls for selections, sort order and
destination and can be condensed as only having a print and cancel button. In this
case the report contains everything that is needed to integrate or all options are
fully coded in the report or ReportView object. Copying the report object and a
print button to a view like the order view to only print the current order is fully supported.
2.2.2 Report integration for Web applications To start the wizard, go to the File menu and choose the ‘New’ option followed by the ‘Web Object’ option. The
dialog to select from looks like:
For the explanation of the wizard that follows it is assumed that:
• The ‘WebOrder’ workspace is selected.
• The DataFlex Reports library is added to that workspace.
• A simple report, named CustomerList.dr, was created with DataFlex Reports in the Reports folder
showing customer data. A report with this name is present.
• The Web project (WebApp.src) is selected in the workspace.
The first window explains the function of the wizard. Click ‘Next’ to proceed.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 14 of 247 z
Business Software for a Changing WorldTM
On the next page select the
report named
CustomerList.dr. The wizard
looks in a folder Reports but
the browse button can be
used to select a report from
another folder. Selecting a
report from another folder
has impact on the
functionality of the wizard and
the integration library.
Selection list usage will not be
made available for reports
from a folder outside the
workspace. If the report is
based on tables of the
DataFlex embedded database
paths to the database or
individual tables can be
automatically corrected to the
workspace paths. Select the checkbox “Auto correct DataFlex table paths to workspace paths” if this is desired. It
should not be selected if report contains tables that are not present in the workspace without developer coding.
In such a case it might be needed to write own code to connect report to data. If the data is retrieved from an
ODBC or RDS data-source this option has no meaning. The preview button can be used to preview the report to
discover if the correct report was selected. Running a report without selection criteria might take a while and
previewing should not be chosen.
It is not possible to continue if the report was
not created with the same version of the
installed DataFlex Reports OCX. An error as
shown here will be presented.
In such a case the report needs to be opened in
the DataFlex Reports designer and saved to disk.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 15 of 247 z
Business Software for a Changing WorldTM
In the next wizard page the
name of the report view
object, the name of the
source file on disk and a
description can be entered.
The default values shown are
based on the name of the
selected and opened report.
A confirmation question pops
up if there is already a file
with the entered name.
The name of the object needs
to be unique in the web
project.
Printed in bold is shown that
this report view will be added
to WebApp.src which is a
confirmation that the correct
project type was chosen.
In the next wizard page fields
can be selected for which the
wizard creates input controls
allowing the end-user to make
selections.
For each selected field a
group object with a ‘from’ and
‘to’ value input control will be
created.
The wizard will automatically
create a connection to a
selection list component if the
workspace contains a data
dictionary class for the table
of the selected columns. A
drop-down (webcombo)
control will be created if the
data dictionary contains a
validation table for the
selected columns. If no data dictionary can be found or if the report uses ODBC or RDS data this feature cannot
be offered and the developer would need to write own coding.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 16 of 247 z
Business Software for a Changing WorldTM
The next wizard page depends
on the report definition. If the
report contains a filter (expert
and/or filter function) the next
wizard page(s) show the
filters. Editing of the filter is
not possible; selecting to keep
or remove the filters can be
done via the radios below the
grid.
Keeping the filter definitions
results in a report that filters
the data on the predefined
filter plus the values from the
selection input controls.
The next wizard page again
depends on the report
definition. If the report
contains parameters, the
CustomerList.dr does not contain parameters, a page will be shown in which parameters can be selected for
which an input control will be created. A checkbox below the list of parameters make it possible to ask the
wizard to generate source code for the parameters that were not selected. Via source code these parameters
can be given a value. The reference further in this guide handles the parameter usage.
An input control will be
generated for each of the
selection and or parameter
fields.
The generated label for the
input control can be changed
in the labels and alignment
wizard page.
On the same wizard page the
label justification mode can be
chosen by clicking the
corresponding radio in the
‘Justification’ group.
After clicking Next the wizard
makes it possible to set the
sort order of the data
displayed in the details
section of the report.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 17 of 247 z
Business Software for a Changing WorldTM
The wizard shows the record
sort order defined in the
report if any.
With a right mouse click the
sort direction (ascending or
descending) can be selected
per column. The floating
menu also makes the sort
order change-able.
With the checkboxes
underneath the selected sort
columns list it is possible to
indicate that code needs to
be written that allows the
user to change the sort order
and if this is a single sort
order or a multi column sort
order.
The next step in the wizard
depends again on the report.
If the report or one of the
sub-reports contains user
defined functions the wizard
shows these functions.
Each of the functions can be
inspected and selected for
code generation. Functions
that are designed to have a
different value than entered
during report creation can be
changed via source code.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 18 of 247 z
Business Software for a Changing WorldTM
In the next wizard page a
choice needs to be made
regarding output type and
destination.
Output can be created as PDF,
RTF, TIFF, HTML, JPEG or GIF.
These are – besides Excel – all
the export formats supported
by DataFlex Reports. The
default option is PDF.
Interactive reports can be
made with an HTML output
type.
The graphic formats (TIFF,
JPEG, GIF) produce the output
in one or more files than can
be downloaded or shown in a
viewer control.
Based on the chosen output option (PDF etc.) a
choice can be made between one or more
destination types. The picture shows the options for
PDF. When multiple fields are selected for input
control generation (selection criteria, parameters)
the best choices are “iFrame On Tab in View”, “New Window” or “New Tab” due to the lack of space in the other
two options.
A web report view contains a column layout. The value for the number of columns in the web view can be
entered. Default is 10 and is usually ok. The value can be changed later in the DataFlex Studio. Optionally a view
width can be entered. No value means full width of the browser.
The option “Create tool-bar” places the “run report” button on a tool-bar
inside the report view.
Note: The chosen theme needs to support tool-bars. That is why the option
is not pre-selected.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 19 of 247 z
Business Software for a Changing WorldTM
In the next step of the wizard
it is possible to choose if an
instruction to set a language
should be generated for
translation of language items
such as “Page N of M” into the
chosen language.
Sorting inside DataFlex
Reports uses a collating
sequence which is maintained
in a file. By default the
DataFlex development
collating sequence file
(df_collate.cfg in the bin
folder) is copied to the
DataFlex Reports design
environment during
installation. The integration
might need to use a different
collating sequence to that of the application and this can be done by specify the path to and the name of the file
with the (different) collating sequence information.
If the report is based on an ODBC data-source the third option can be selected which generates code in the
report object in which a change in the data-source can be programmed.
Next step in the process is finishing the wizard and the generation of the source code. The generated code will
be loaded in the DataFlex Studio and the newly generated component will be added to the webapp project and
the ‘View” pull-down.
The generated source code contains a cDRReport object to load the DataFlex Reports report. Inside the object a
main event named OnInitializeReport will be present. This is executed when the report loads and in this example
case sends messages to setup report filters and records sorts.
In the SetFilters method values from the input controls for selection criteria (and if present from parameters) are
retrieved. For this a WebGet statement is generated. Since the selection criteria input controls are always in a
from-value to-value way both values are placed in an array type variable which get automatically sorted to get
the lowest value in the first array element. A TODO item is generated to let the developer examine this and
decide if this array sorting should be kept or not. The selection criteria are added to the report data by sending
an AddFilter message.
The SetSortFields is another method to pay attention to. If the “Multi level sort order” option was chosen the
values – to be used with an AddRecordSortField message – are retrieved in a 2-dimensional array consisting of
column and direction pairs.
The method GenerateReport is the starting method for getting the report results. The method is started from
the RunReport method in the web view or from the HTML/Image viewer control. The function returns a string
with a filename (PDF, TIFF) or an array of data or filenames (HTML, GIF, JPEG). In the method the report is
opened and closed. Between this the export options are set to a default which can be changed.
Developers are free to change the layout of the generated web view. Change object references if object names
(such as oReport and oViewer) are changed.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 20 of 247 z
Business Software for a Changing WorldTM
The above screenshots are examples of generated web views for report integration.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 21 of 247 z
Business Software for a Changing WorldTM
2.3 DataFlex Reports Application Programming Interface Any report built by DataFlex Reports stores its definition in the file with the .DR extension. The definition is read
by the DataFlex Reports Runtime, which is actually an OCX. The OCX (named DataFlex Reports 2014
Developer Edition API.ocx) can do more than just represent a report. The runtime OCX contains several
functions that are made available to programmers.
The interface functions can be grouped in sections for report, preview, data source, filter, function, columns,
export and progress. The following paragraphs provide a quick overview per group.
2.3.1 Column interface ColumnCount String sReportId Integer iTable Returns Integer
ColumnIndex String sReportId Integer iTable Integer iColumn Returns Integer
ColumnLength String sReportId Integer iTable Integer iColumn Returns Integer
ColumnName String sReportId Integer iTable Integer iColumn Returns String
ColumnPrecision String sReportId Integer iTable Integer iColumn Returns Integer
ColumnType String sReportId Integer iTable Integer iColumn Returns Integer
2.3.2 Data source interface DatabaseCollate String sReportId Returns String
DatabaseConnection String sReportId String sConnection
DatabaseName String sReportId String sDatabaseName
DatabaseType String sReportId Returns Integer
TableCount String sReportId Returns Integer
TableData String sReportId Integer iTable Variant[] vData
TableName String sReportId Integer iTable String sName
TableSchema String sReportId Integer iTable String sSchema
2.3.3 Export interface CSVExportOptions String sReportId Integer pData
HTMLExportOptions String sReportId Integer pData
ImageExportOptions String sReportId Integer pData
PDFExportOptions String sReportId Integer pData
ReportExport String sReportId Integer iType String sFileName
ReportHTMLPreview String sReportId Integer iArgSize Returns String[]
XLSExportOptions String sReportId Integer pData
2.3.4 Filter interface FilterFunction String sReportId String sFilter
RecordFilterAdd String sReportId String sField Integer eOperator String sValue
RecordFilterCount String sReportId Returns Integer
RecordFilterDelete String sReportId Integer iFilter
RecordFilterField String sReportId Integer iFilter String sField
RecordFilterOperator String sReportId Integer iFilter Integer eOperator
RecordFilterValue String sReportId Integer iFilter String sValue
2.3.5 Function interface Function String sReportId Integer iFunction Returns String
FunctionByName String sReportId String sFunctionName Returns Integer
FunctionCheck String sReportId String sFunction Integer iIndex Returns Integer
FunctionCount String sReportId Returns Integer
FunctionError String sError Integer iLine Integer iColumn String sToken
FunctionIsEmpty String sReportId String sFunction Returns Integer
FunctionIsSymbolUsed String sReportId String sSymbol Returns Integer
FunctionLength String sReportId String sFunction Returns Integer
FunctionName String sReportId Integer iFunction Returns String
FunctionType String sReportId String sFunction Returns Integer
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 22 of 247 z
Business Software for a Changing WorldTM
2.3.6 Language interface ReportLanguage String sReportId Returns Integer
ReportLanguageList String sReportId Returns Variant
2.3.7 Parameter interface ParameterByName String sReportId String sParameterName Returns Integer
ParameterCount String sReportId Returns Integer
ParameterLength String sReportId Integer iParameter Returns Integer
ParameterName String sReportId Returns String
ParameterPrecision String sReportId Integer iParameter Returns Integer
ParameterType String sReportId Returns Integer
ParameterValue String sReportId Integer iParameter Returns String
2.3.8 Preview interface PreviewClick Integer iPos Integer iSectionId String
PreviewCurrentPage Integer iPage
PreviewFind String sString Integer bDown Integer bWholeWord Integer bMatchCase
PreviewFirstPage
PreviewHWND Integer hWnd
PreviewLastPage
PreviewNextPage
PreviewPreviousPage
PreviewShowPage Integer iPage
PreviewZoom Integer iZoom
PreviewZoomChanged Integer iZoom
2.3.9 Print interface PaperOrientation String sReportId Returns Integer
PaperSize String sReportId Returns Integer
ReportPrint String sReportId Integer hPrintDlg
2.3.10 Progress interface ProgressCountPage Integer iPage
ProgressExportPage Integer iPage Integer iTotalPages
ProgressFormatPage Integer iPage Integer iTotalPages
ProgressRecordsRead Integer iRecords
2.3.11 Report interface ReportCancel String sReportId
ReportClose String sReportId
ReportError Integer iError String sError
ReportInfo Integer iError String sError
ReportName String sReportId Returns String
ReportOpen String sReport Returns String
ReportPageCount String sReportId Returns Integer
ReportPreview String sReportId
ReportQuery String sReportId Returns String
ReportRefresh String sReportId
ReportStatistics Integer iType Integer iValue
SubReportCount String sReportId Returns Integer
SubReportId String sReportId Integer iIndex Returns String
2.3.12 Sort interface RecordSortAdd String sReportId String sSortField Integer eSortOrder
RecordSortCount String sReportId Returns Integer
RecordSortDelete String sReportId Integer iIndex
RecordSortField String sReportId Integer iIndex Returns String
RecordSortOrder String sReportId Integer iIndex Returns Integer
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 23 of 247 z
Business Software for a Changing WorldTM
2.4 cDRReport class The cDRReport class is a subclass of the cDRAPI ActiveX wrapper class, which should not be used for object
instantiation. For this the cDRAPI class is marked as abstract and thus the cDRReport class should be used. The
interface in the cDRReport class protects against writing incorrect code instructions.
For printer selection and controlling the PrintReport method you use an object of the cPrintDialog class, which is
a class that we supply with the DataFlex Reports library.
2.4.1 How to use the cDRReport class Running reports side-by-side can be done by creating multiple instances of the cDRReport class at the same
time, if the preview output is not sent to a modal dialog. Running ReportA and then ReportB can be done using
one instance of the cDRReport class.
The most important property of the cDRReport object is the psReportName property which needs to be set to
the filename of the report (e.g. CustomerList.dr). Without this the engine won’t know what report to execute.
The property can be set in a static or dynamic way. The report file name in psReportName may contain a path.
Normally no path is given if the report resides in a folder of the application’s workspace. If a path is not specified
an attempt is made to locate the report by the OpenReport function. The following sequence is used to locate
the report, until the report file is found or no report file by the specified name is found.
1. The folder location can be stored in a property named psReportPath. Even if this property is not empty the
report file may not be there.
2. Only when compiling and running with DataFlex 17.1 or later, the Reports folder is searched for the report.
The location of the Reports folder is returned by a function named ReportsFolder. The default is a folder
named Reports in the root of the workspace.
3. The folders of the application’s data paths are enumerated to locate the report. The application’s data paths
are stored in the DataPath setting in the workspace file (e.g config.ws). This value is programmatically
accessible via the psDataPath property of the workspace object in the application.
Note that when the project does not have an application object (instance of cApplication) – this is very rare –
there is no workspace object, there are no data paths, there is no Reports folder. The path to the report
filename needs to be part of the file in the psReportname or the psReportPath property must be set to the
location of the reports.
Before report settings can be queried or altered the report must be opened using the OpenReport function. The
OpenReport function returns the report ID, which is a GUID (Globally Unique Identifier). If the report cannot be
opened the return value will be an empty string.
If the report uses tables from the DataFlex embedded database (or tables from an external database described
by intermediate (INT) files) the class will attempt to automatically locate the database and tables and adjust
paths in the report at runtime. This change of table location is not persistent. If the workspace contains multiple
tables with the same name or when it uses a different technique to locate and open tables it is better to set the
pbAutoLocateDFFiles property to false.
If a manual change of the location of the database and tables is desired the properties psDatabaseName,
DatabaseType, psDatabaseConnection, and psTableSchema should be used. psDatabaseName contains the
name of the filelist or the first table in an environment using the embedded DataFlex database, DatabaseType
indicates whether it is an embedded DataFlex database that is used or an ODBC datasource,
psDatabaseConnection contains the DataFlex DF_OPEN_PATH or the DSN that gives access to the ODBC
datasource, and psTableSchema contains the path to a table when the embedded DataFlex database is used and
tables are not opened via the filelist or the table schema if available in case of an ODBC datasource.
The property psTableName returns the name of the N-th table in the report. The function TableCount returns
the number of tables present in the report. If the report is based on an ODBC or Stored Procedure datasource it
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 24 of 247 z
Business Software for a Changing WorldTM
is possible to let the integration wizard generate code to assist in changing the DSN for the report, look for a
method called ChangeODBCDataSource.
An opened report can be displayed; its data can be exported or printed to a print device. Sending the RunReport
message to the report will open the report and then output the report to screen, printer or file. The method of
output is controlled by the property peOutputDestination which can have the values PRINT_TO_WINDOW,
PRINT_TO_PRINTER, PRINT_TO_PRINTER_NO_DIALOG or PRINT_TO_FILE. The report remains open after output. If
the report was not opened before sending RunReport to the report object results in an attempt to open the
report by calling the OpenReport method. As mentioned above the OpenReport message can be send to only
open the report and change or query some settings with or without creating output.
During OpenReport it is possible to show a status panel to the end-user. This is controlled by the property
pbShowStatusPanel in combination with the property phoStatusPanel that holds the object id of the statuspanel.
Both properties need to be set by the developer and are false and 0 by default.
If the output of the report is expected to take some time it would be good to display information about reading
and processing data to the end-user. This can be done by implementing the event OnProgressRecordsRead and
displaying the number of records read and/or the event OnProgressFormatPage to display how many pages have
been formatted out of the total number of pages. The integration wizard already writes the code for these
events in the cDRReport object.
Instead of running the report and depending on the property peOutputDestination it is possible to open the
report (with the OpenReport function) and then either send the message DisplayReport, ExportReport or
PrintReport. The report must be opened before one of these three messages can be sent.
When the report executes, the DataFlex application continues to respond to mouse clicks, function keys etc.
since the report data reading and formatting process is done in an ActiveX module.
For exporting or printing the report it is not necessary for the ActiveX to be displayed in a DataFlex container
object (e.g. a (db)View).
After opening the report, record filters can be set in two ways. One way is via the psFilterString property. The
syntax of the VB Like function code that needs to be written for this function can be checked via the function
TestFilterFunction. It is not a requirement though. The second way is via the methods AddFilter, RemoveFilter,
RemoveAllFilters. Existing filters can be altered via the method FilterCount in combination with the properties
psFilterField, peFilterOperator and psFilterValue.
The class also gives access to any of the stored functions in the report. The number of functions can be queried
via the method FunctionCount. Each function can be addressed via the methods psFunctionName and
psFunction. If the function name is known, the FunctionIdByName returns the function ID. It is not possible to
add new functions to the report, only to change existing functions.
A report may contain one or more sub-report(s). A sub-report may contain one or more other sub-report(s). The
number of nested sub-reports is not limited but using sub-reports has an impact on the execution speed. The
number of sub-reports in a report can be queried via the method SubReportCount and their IDs can be retrieved
via the function SubReportID. The sub-report can and should be further accessed in its entirety as if it was a
report on its own. If the pbAutoLocateDFFiles is set to false (or when an ODBC data-source is used) the data-
sources in the sub-report(s) needs to be adjusted manually (if needed). Each method that requires the passing of
a report id can have the main report id or the id of a sub-report passed.
For exporting the report a choice can be made between export to image, to CSV (Comma Separated Values), to
XLS (Excel), to HTML or to PDF (Portable Document Format). In all five options a variable with the appropriate
settings for the export format needs to be passed. For this use the write only properties pImageExportOptions,
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 25 of 247 z
Business Software for a Changing WorldTM
pCSVExportOptions, pXLSExportOptions, pHTMLExportOptions or pPDFExportOptions. The DataFlex Reports
print engine may crash if these properties are not set with appropriate information prior to the export.
When the report is displayed in the viewer and page navigation controls are desired, documentation about the
methods PreviewFirstPage, PreviewLastPage, PreviewNextPage, PreviewPreviousPage and the property
piPreviewPage should be read.
Any errors that are generated during any of the class methods, or which are sent to the object by the viewer
OCX, are automatically handled by the cDRReport object itself. As with the usual global DataFlex error handler
the method Error_Report is used. This method first determines if it is handling errors already and if so skips the
new error to avoid recursion. The next step in the process is calling the OnError event which could be used to log
error information into a log-file, send an e-mail etc. When the property pbDisplayError is set to true (the default
is True) the error is passed to the standard error handler object. In the OnError event the pbDisplayError could
be set to false to avoid having the standard DataFlex error handler picking up the error. If the property
pbCancelIfError is true (the default is True) the pbCanceled property will be set to true to avoid follow-up errors
in other report methods.
Closing the report can be done with the CloseReport message. Don't do this while the report is still needed (e.g.
in viewing pages). When a different report is opened the old report will automatically be closed. When the
ActiveX object is deactivated (the dialog to where it was paged is deactivated or during destroy) the currently
opened report will be closed as well.
While using the DisplayReport message (or RunReport with the peOutputDestination set to PRINT_TO_WINDOW,
which is the default) the report object should have a size big enough to display the report, or the preview
window handle has to be set to an object big enough to display the report results. The minimum size of the
cDRReport object has to be 2 by 2.
Report errors and special fields in the report can displayed/printed in a specific language. Use the
piReportLanguage property for specifying the language. The text strings for this language support are read from
a database named language.db which is delivered with DataFlex Reports. A set of popular languages are
delivered with DataFlex Reports.
If the data is sorted locally, the sort order is configurable when using ODBC and is standard for DataFlex data.
The used collating sequence can be queried or set using the psDatabaseCollate method. The method needs to
point to a valid collating sequence file.
Reports can be based on runtime data. To pass data the application has to build a two dimensional variant array
that matches the data source defined in the report and fill it with the data to be displayed, exported or printed.
The variant array is passed to the report via the TableData method.
A report can be based on a stored procedure that delivers the data to the report. The optional parameters of a
stored procedure can be accessed via the methods ParameterCount, ParameterName, ParameterType and the
property psParameterValue. These same methods and the property can be used for parameters defined in the
report.
Preview results can be shown via the ActiveX object on a (report)view, in a modal dialog, an MDI view or a tool-
panel. The pePreviewStyle property controls the display “channel”.
Many functions and properties take a report ID as first argument. This report ID is the GUID (string
representation) returned by the OpenReport function. The value can be passed as an empty string (or
C_USEMAINDRREPORTID) if the main report is should be used. The function or property retrieves the psReportID
property value for the report ID.
In the next paragraphs detailed information about the properties, the methods and the events of the cDRReport
class can be found.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 26 of 247 z
Business Software for a Changing WorldTM
2.4.2 Translation All messages and constants used in the cDRReport class and dialogs are available in a number of languages. For
each language the file that contains the translations is named DRLanguage.inc (e.g.
DRLanguageDeutsch.inc) and is usually included by adding DRLanguage.inc into the top of the code that needs
the translation. The choice for the correct text strings is the same as in the rest of the DataFlex applications,
which means that the compiler constant Language$Current determines what the translation is.
Requests for additional languages can be send to Data Access Europe by e-mail ([email protected]).
The integration wizard uses dynamic translation following the language choice in the DataFlex Reports designer.
The translation strings are read from a database named language.db located in the programs folder where the
integration wizard is installed. When the translation cannot be found the default English translation is used. Note
that both the DataFlex Reports designer and the integration wizard use a database named language.db but that
the contents differ. The language.db for the designer does not work for integration and vice-versa.
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 27 of 247 z
Business Software for a Changing WorldTM
2.4.3 Properties
pbAllowMaximizeView
Type: Boolean
Default: False
Arguments: -
Description: This property is used by the cDRPreview class to set the Maximize_Icon of the dynamically created view.
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Set pbAllowMaximizeView to True
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sReportId
Get OpenReport of oReport to sReportId
If (sReportId '') Begin
Send DisplayReport of oReport
End
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 28 of 247 z
Business Software for a Changing WorldTM
pbAutoLocateDFFiles
Type: Boolean
Default: True
Arguments: -
Description: The location of database and tables for a DataFlex data-source in the report (and sub-reports) is changed during OpenReport into a location relative to the workspace data paths. The system only does this with tables without a path or when the path is invalid when the DatabaseType indicates the report uses the DataFlex database as data source. The example shows what can be done if pbAutoLocateDFFiles is false.
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Set pbAutoLocateDFFiles to False
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sReportId
Get OpenReport of oReport to sReportId
If (sReportId '') Begin
Set psDatabaseName of oReport to ;
'c:\project\data\filelist.cfg'
Send DisplayReport of oReport
End
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 29 of 247 z
Business Software for a Changing WorldTM
pbCanceled
Type: Boolean
Default: False
Arguments: -
Description: A developer may choose to cancel the report in OnInitializeReport, OnPrintReport, OnExportReport or OnDisplayReport by setting this property to True. If the property pbCanceled is set to True the print, display or export will be cancelled.
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sReportId
Get OpenReport of oReport to sReportId
If (sReportId '') Begin
// We can now break its further actions
Set pbCanceled of oReport to True;
// Now report will not be printed
Send DisplayReport of oReport
End
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 30 of 247 z
Business Software for a Changing WorldTM
pbCancelIfError
Type: Boolean
Default: True
Arguments: -
Description: Determines if the report handling will be canceled when an error occurs.
Sample: Object oReport is a cDRReport
// invoke an error with a non-existent report
Set psReportName to 'NonExistentReport.dr'
Set pbCancelIfError to False
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
Boolean bHasErrors
Send DisplayReport of oReport
Get pbHasErrors to bHasErrors
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 31 of 247 z
Business Software for a Changing WorldTM
pCSVExportOptions
Type: drCSVExportOptions structure, see 2.18.1
Default: See 2.18.1
Arguments: -
Description: This write-only property needs to be set before export to CSV (ExportReport) can be done. The property needs to be set to a value of the drCSVExportOptions data-type. This property cannot be set before the report OCX object is initialized and a report is opened (OpenReport). The function DefaultCSVExportOptions can be called to initialize the drCSVExportOptions variable.
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
End_Object
Object oExportReportButton is a Button
Set Label to 'Export Report'
Procedure OnClick
drCSVExportOptions CSVExportOptions
String sReportId
Get OpenReport Of oReport To sReportId
// set the export options
Move '”' to CSVExportOptions.cFieldDelimiter
Move ',' to CSVExportOptions.cFieldSeparator
Move False to CSVExportOptions.bExportGroupSections
Move False to CSVExportOptions.bExportPageSections
Move False to CSVExportOptions.bExportReportSections
Move True to CSVExportOptions.bAllPages
Move 1 to CSVExportOptions.iPage
Set pCSVExportOptions of oReport to CSVExportOptions
// exports the report to a file named ExportFile.csv
Send ExportReport of oReport C_drCSV 'ExportFile.csv'
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 32 of 247 z
Business Software for a Changing WorldTM
psDatabaseConnection
Type: String
Default: -
Arguments: Argument Description sReportId ID of the report to query. Can be ID of the main report or the ID of a
sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
Description: If the data source is DataFlex, this property holds the DF_OPEN_PATH used to locate the DataFlex filelist and tables. If the data source is ODBC, this property holds the ODBC connection string (e.g. DSN=Dynamic AI Library Demo;DBQ=C:\Program Files\Dynamic AI\Dat\Dynamic AI Library
Demo.mdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5). If the data source is RDS (Runtime Data Source), this holds the static name "Runtime Datasource". This property cannot be accessed before the report OCX object is initialized and a report is opened (OpenReport).
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
Integer eDatabaseType
String sDatabaseConnection
Send RunReport of oReport
Get psDatabaseConnection of oReport '' to sDatabaseConnection
Get DatabaseType of oReport C_USEMAINDRREPORTID to eDatabaseType
If (eDatabaseType = C_drDF) Begin
Send Info_Box ('paths = ' + sDatabaseConnection)
End
If (eDatabaseType = C_drODBC) Begin
Send Info_Box ('connection string = ' + sDatabaseConnection)
End
If (eDatabaseType = C_drRDS) Begin
Send Info_Box ('connection string = ' + sDatabaseConnection)
End
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 33 of 247 z
Business Software for a Changing WorldTM
psDatabaseName
Type: String
Default: -
Arguments: Argument Description sReportId ID of the report to query. Can be ID of the main report or the ID of a
sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
Description: If the data source is DataFlex and the filelist was used to select tables this property holds the name and path of the filelist.cfg file. If individual tables were used this property holds the name of the first table in the report. If the data source is ODBC, this holds the name of the database (Catalog name). If the data source is RDS, this holds the static name "Runtime Datasource". This property cannot be accessed before the report OCX object is initialized and a report is opened (OpenReport).
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
Integer eDatabaseType
String sReportId sDatabaseName
Send RunReport of oReport
Get psReportId of oReport to sReportId
Get psDatabaseName of oReport sReportId to sDatabaseName
Get DatabaseType of oReport sReportId to eDatabaseType
If (eDatabaseType = C_drDF) Begin
Send Info_Box ('filelist = ' + sDatabaseName)
End
If (eDatabaseType = C_drODBC) Begin
Send Info_Box ('catalog = ' + sDatabaseName)
End
If (eDatabaseType = C_drRDS) Begin
Send Info_Box ('database = ' + sDatabaseName)
End
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 34 of 247 z
Business Software for a Changing WorldTM
pbDisplayError
Type: Boolean
Default: True
Arguments: -
Description: Determines if errors will be displayed during the execution of the report. For the display of the errors the standard DataFlex error handler system will be used by sending Error_Report of the object whose ID was in the global Error_Object_Id variable prior to a method execution. The code in the example below shows the use of error logging in case errors are not displayed.
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Procedure OnError Integer iErrNum Integer iErrLine String sErrMsg
Boolean bDisplayError
Integer iChannel
Get pbDisplayError to bDisplayError
If (not (bDisplayError)) Begin
Move (Seq_New_Channel ()) to iChannel
If (iChannel >= 0 and iChannel
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 35 of 247 z
Business Software for a Changing WorldTM
psExportFileName
Type: String
Default: -
Arguments: -
Description: Sets/Gets the name of the file used to export to. Needs to be set before calling OutputReport when peOutputDestination is set to PRINT_TO_FILE.
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sReportId
drImageExportOptions ImageExportOptions
Get OpenReport of oReport to sReportId
Set peExportType of oReport to C_drImage
Set psExportFileName of oReport to 'MyOutput.jpg'
// set the export options for image export
Move C_drJPEG to ImageExportOptions.iImageType
Move False to ImageExportOptions.bMultiPage
Move 2 to ImageExportOptions.iPage
Set pImageExportOptions of oReport to ImageExportOptions
Send OutputReport of oReport
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 36 of 247 z
Business Software for a Changing WorldTM
phoExportOptionsDialog
Type: Handle
Default: In Windows applications: the object id of oDRExportOptionsDialog. In Web applications: 0.
Arguments: -
Description: Contains the handle of a dialog that can be shown to handle export options. It is used by OutputReport if peOutputDestination is set to PRINT_TO_FILE and psExportFileName is empty. An ExportReport message is sent to this handle.
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Set peOutputDestination to PRINT_TO_FILE
Set phoExportOptionsDialog to oMyOwnExportOptionsDialog
End_Object
Object oOutputReportButton is a Button
Set Label to 'Output Report'
Procedure OnClick
String sReportId
Get OpenReport of oReport to sReportId
Send OutputReport of oReport
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 37 of 247 z
Business Software for a Changing WorldTM
peExportType
Type: Integer
Default: C_drPDF
Arguments: -
Description: Gets/Sets the type of export. This property has to be set before sending the message OutputReport when the peOutputDestination property is set to PRINT_TO_FILE. The corresponding export options (pPDFExportOptions, pCSVExportOptions, pImageExportOptions, pHTMLExportOptions or pXLSExportOptions) should be set as well. If not set, the default values (documented in paragraph 2.17.3) are used. Possible values:
Argument Description C_drCSV Export to Comma Separated Values (CSV) C_drHTML Export to HTML C_drImage Export to image (JPEG, TIFF, GIF, or PNG) C_drPDF Export to Portable Document Format (PDF) C_drRTF Export to Rich Text Format (RTF) C_drXLS Export to XLS or XLSX
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sReportId
drCSVExportOptions CSVExportOptions
Get OpenReport of oReport to sReportId
Set peExportType of oReport to C_drCSV
Set psExportFileName of oReport to 'MyOutput.csv'
// set the export options for the above specified CSV export
Move '"' to CSVExportOptions.cFieldDelimiter
Move '|' to CSVExportOptions.cFieldSeparator
Move True to CSVExportOptions.bExportGroupSections
Move True to CSVExportOptions.bExportPageSections
Move True to CSVExportOptions.bExportReportSections
Move False to CSVExportOptions.bSinglePage
Move 1 to CSVExportOptions.iPage
Set pCSVExportOptions of oReport to CSVExportOptions
Send OutputReport of oReport
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 38 of 247 z
Business Software for a Changing WorldTM
psFilterField
Type: String
Default: -
Arguments: Argument Description sReportId ID of the report to query. Can be ID of the main report or the ID of a
sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
iField The 0-based index of the filter.
Description: Sets/Gets the N-th filter field name of a report. Filters can be added in the designer via the filter expert dialog or via the AddFilter method. Trying to set psFilterField of a non-existing filter does not do anything and gives no error. Use this property together with peFilterOperator and psFilterValue. This property cannot be accessed before the report OCX object is initialized and a report is opened (OpenReport).
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Procedure OnInitializeReport
Forward Send OnInitializeReport
Set psFilterField '' 0 to '{Titles.YearPublished}'
Set peFilterOperator '' 0 to C_drEqual
Set psFilterValue '' 0 to 1984
End_Procedure
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sFilterField
Send RunReport of oReport
Get psFilterField of oReport C_USEMAINDRREPORTID ;
0 to sFilterField
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 39 of 247 z
Business Software for a Changing WorldTM
psFilterFunction
Type: String
Default: -
Arguments: Argument Description sReportId ID of the report to query. Can be ID of the main report or the ID of a
sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
Description: Sets/Gets the filter function of a report. Note that it is VB Like, not DataFlex. Although the contents of the filter function are executed for each record, dependent on the result (true or false), the record will or will not be used for the report. An attempt is made to perform a jump into and out of index with the returned value. For such an operation do not use a complex function with, for example, an IF statement. This property cannot be accessed before the report OCX object is initialized and a report is opened (OpenReport).
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Procedure OnInitializeReport
Forward Send OnInitializeReport
Set psFilterFunction '' to ;
'return ({Titles.YearPublished} = 1984)'
End_Procedure
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sFilterFunction
Send RunReport of oReport
Get psFilterField of oReport C_USEMAINDRREPORTID ;
to sFilterFunction
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 40 of 247 z
Business Software for a Changing WorldTM
peFilterOperator
Type: Integer
Default: -
Arguments: Argument Description sReportId ID of the report to query. Can be ID of the main report or the ID of a
sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
iField The 0-based index of the filter.
Description: Sets/Gets the N-th filter operator of a report. Filters can be added in the designer via the filter expert dialog or via the AddFilter method. Trying to set peFilterOperator of a non-existing filter does not do anything and gives no error. Use this property together with psFilterField and psFilterValue. This property cannot be accessed before the report OCX object is initialized and a report is opened (OpenReport). The possible filter operators are: C_drNone
C_drEqual
C_drNotEqual
C_drGreaterThan
C_drGreaterThanOrEqual
C_drLessThan
C_drLessThanOrEqual
The use of C_drNone only makes sense when the DatabaseType is C_drDF and you have a 3 or more segment index where you want to skip the second or subsequent value but want to make use of the next values.
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Procedure OnInitializeReport
Forward Send OnInitializeReport
Set psFilterField '' 0 to '{Titles.YearPublished}'
Set peFilterOperator '' 0 to C_drLessThan
Set psFilterValue '' 0 to 1990
End_Procedure
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sFilterOperator
Send RunReport of oReport
Get psFilterOperator of oReport C_USEMAINDRREPORTID ;
0 to sFilterOperator
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 41 of 247 z
Business Software for a Changing WorldTM
psFilterValue
Type: String
Default: -
Arguments: Argument Description sReportId ID of the report to query. Can be ID of the main report or the ID of a
sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
iField The 0-based index of the filter.
Description: Sets/Gets the N-th filter value of a report. Filters can be added in the designer via the filter expert dialog or via the AddFilter method. Trying to set psFilterValue of a non existing filter does not do anything and gives no error. Use this property together with psFilterField and peFilterOperator. This property cannot be accessed before the report OCX object is initialized and a report is opened (OpenReport).
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Procedure OnInitializeReport
Forward Send OnInitializeReport
Set psFilterField '' 0 to '{Titles.YearPublished}'
Set peFilterOperator '' 0 to C_drGreaterThanOrEqual
Set psFilterValue '' 0 to 1963
End_Procedure
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sFilterValue
Send RunReport of oReport
Get psFilterValue of oReport C_USEMAINDRREPORTID ;
0 to sFilterValue
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 42 of 247 z
Business Software for a Changing WorldTM
psFunction
Type: String
Default: -
Arguments: Argument Description sReportId ID of the report to query. Can be ID of the main report or the ID of
a sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
sFunctionName Name of the function to retrieve or set the contents of.
Description: Sets/Gets the contents of a function defined in the report. If the report does not contain a function with the passed function name you will get an error. You can use the function FunctionIdByName to find out if a function with a certain name exists or not. The function will return the function id and when this is -1 (negative 1) the function does not exist. This property cannot be accessed before the report OCX object is initialized and a report is opened (OpenReport).
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
String sReportId
Send OpenReport of oReport to sReportId
Set psFunction of oReport sReportId 'Version' ;
to 'return "1.0.0.15"'
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 43 of 247 z
Business Software for a Changing WorldTM
psFunctionName
Type: String
Default: -
Arguments: Argument Description sReportId ID of the report to query. Can be ID of the main report or the ID of
a sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
iFunctionId The N-th function in the report.
Description: Sets/Gets the name of the N-th function defined in the report. Use the method FunctionCount to find out how many functions there are. This property cannot be accessed before the report OCX object is initialized and a report is opened (OpenReport).
Sample: Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
Integer iFunction iFunctions
String[] sFunctionNames
String sReportId sSubReportId
Get OpenReport of oReport to sReportId
Get SubReportId Of oReport sReportId 1 to sSubReportId
Get FunctionCount of oReport sSubReportId to iFunctions
Move (ResizeArray (sFunctionNames, iFunctions)) to sFunctionNames
Decrement iFunctions
For iFunction From 0 To iFunctions
Get psFunctionName of oReport sSubReportId iFunction to ;
sFunctionNames[iFunction]
Loop
Send CloseReport sReportId
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands
Page 44 of 247 z
Business Software for a Changing WorldTM
pbHasErrors
Type: Boolean
Default: False
Arguments: -
Description: If an error occurred in a report execution or loading the value of this property will be True and your code can take decisions based on this state. The OnError event can be used to log errors; shown in the sample code.
Sample: Object oReport is a cDRReport
// invoke an error with a non-existent report
Set psReportName to 'NonExistentReport.dr'
Procedure OnError Integer iErrNum Integer iErrLine String sErrMsg
Set pbDisplayError To False
Send WriteToLogFile iErrNum iErrLine sErrMsg
End_Procedure
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
Boolean bHasErrors
Send RunReport of oReport
Get pbHasErrors of oReport to bHasErrors
If (bHasErrors) Begin
Send Info_Box 'An error occurred'
End
End_Procedure
End_Object
+31 74 2555 609 [email protected] www.dataaccess.euData Access Europe B.V. / Lansinkesweg 4 / 7553 AEHengelo, The Netherlands