Flex Report
Flex Report
Trademarks
The ComponentOne product name is a trademark and ComponentOne is a registered trademark of GrapeCity, Inc. All
other trademarks used herein are the properties of their respective owners.
Warranty
ComponentOne warrants that the media on which the software is delivered is free from defects in material and
workmanship, assuming normal use, for a period of 90 days from the date of purchase. If a defect occurs during this
time, you may return the defective media to ComponentOne, along with a dated proof of purchase, and
ComponentOne will replace it at no charge. After 90 days, you can obtain a replacement for the defective media by
sending it and a check for $2 5 (to cover postage and handling) to ComponentOne.
Except for the express warranty of the original media on which the software is delivered is set forth here,
ComponentOne makes no other warranties, express or implied. Every attempt has been made to ensure that the
information contained in this manual is correct as of the time it was written. ComponentOne is not responsible for any
errors or omissions. ComponentOne’s liability is limited to the amount you paid for the product. ComponentOne is
not liable for any special, consequential, or other damages for any reason.
While you are welcome to make backup copies of the software for your own use and protection, you are not
permitted to make copies for the use of anyone else. We put a lot of time and effort into creating this product, and we
appreciate your support in seeing that it is used by licensed users only.
FlexReport for WinForms 1
Table of Contents
FlexReport for WinForms Overview 5
Help with WinForms Edition 5
FlexReport Dissection 24
Components and Controls 24
Object Model Summary 24-26
Sections of FlexReport 26-28
FlexReport Quick Start 29
Step 1 of 4: Creating a Report Definition 29-46
Step 2 of 4: Modifying the Report 46-49
Step 3 of 4: Loading the Report in the C1FlexReport Component 49-50
Background 215-217
Border 217-219
Report and Document Viewer (FlexViewer Control) 220
FlexViewer Key Features 220-221
FlexViewer Toolbar 221-222
Rotate View of Reports 222-223
Binding FlexReport with FlexViewer 223-224
FlexReport Samples 225-226
1. Run C1FlexReportDesigner.4.exe.
2. Go to File|Open and select the C1Report report definition (.xml) that you want to upgrade. You will see the
following dialog box:
3. Click OK.
4. Go to File|Save.
5. In the Save Report Definition File dialog box, specify the File name and click Save.
The report definition is saved as type .flxr. Your report definition is now converted from C1Report's .xml
to C1FlexReport's .flxr.
Upgrading the existing C1Report Windows Application Project to FlexReport Windows Application
Project in Visual Studio
1. Open existing Windows Application project that contains C1Report (.xml) file.
2. Delete C1Report from the Form.
3. Delete C1Report's previewing control C1PrintPreview or C1RibbonPreviewControl from the Form.
4. Add C1FlexReport component to the Toolbox:
a. Right-click a tab and select Choose items... A Choose Toolbox Items dialog box appears.
To use map and super-label custom fields, add following dlls to the references:
C1.Win.FlexReport.CustomFields.4
C1.WPF.Maps.4
C1.WPF.4
9. Rename C1Report component to C1FlexReport component. In code, you can change the name of the
component as follows:
Visual Basic
C#
//To
Visual Basic
C#
//To
C1FlexReport report = new C1FlexReport();
report.Load(filepath, reportname);
c1FlexViewer1.DocumentSource = report;
Note that FlexReport can be previewed at runtime by using FlexViewer control only. The FlexViewer control is
not compatible with C1PrintPreviewControl or C1RibbonPreviewControl.
C1Report.DataSource.RecordSource = “PARAMETERS param1 int 0; select * from Customers where id < param1”.
When C1Report report definitions are loaded in FlexReport, parameters specified using DataSource.RecordSource and DataSource.Filter are
imported correctly into the C1FlexReport.Parameters collection.
Multiple Sub-sections
In C1FlexReport, each section contains at least one sub-section. The sub-sections, just like sections, contain report fields. The advantage of
adding sub-sections is that they help in enhancing the data present in their parent section. Sub-sections can be
accessed through Section.SubSections collection property. For more information, see Adding Multiple Sub-sections.
Visual properties
Borders
In FlexReport, borders can be specified for fields, sub-sections, and sections using VisualReportObject.Border property. In addition,
borders can have each side having its own style and each corner having a different radii for rounded corners. See Border for more
information.
In C1Report, borders can be defined only on fields.
Backgrounds
In FlexReport, backgrounds can be specified for fields, sub-sections, and sections. The background color can be solid or gradient,
which can be set using VisualReportObject.Background property. See Background for more information.
In C1Report, BackColor property is used to set background colors for fields and sections.
In C1Report, parameters can only be specified directly in the DataSource.RecordSource, immediately before the SQL statement
and after the key word PARAMETERS.
In FlexReport, there is a separate dedicated report-level collection C1FlexReport.Parameters, where the report parameters can
be specified. When importing a C1Report report definition from a .xml file, any parameters specified old-style using
PARAMETERS keyword are automatically added to the C1FlexReport.Parameters collection.
In FlexReport, the OnOpen script is fired AFTER the data source has been opened, so any changes to the main data source
made in that script does not affect the report. In order to change something in the data source before the report is generated,
use GlobalScripts. GlobalScripts can contain function and procedure definitions, and codes that are not within these definitions;
all such definitions and codes are now executed when the report starts rendering, before the data source is opened.
In C1Report, Custom fields derived from Field overrides the GetRenderContent() method. The method's signature in
C1FlexReport has been changed to:
If the overriding method sets disposeImage to true, C1FlexReport calls Dispose() on the image after it has been used.
The C1Report.OutlineRootLevel property has been removed. To control the outline structure, use properties OutlineLabel
In C1Report, there are two slightly different methods to generate/layout text - default and 'gdi+' (if
C1Report.UseGdiPlusTextRendering were set to true - non-default). These methods can produce slightly different text layouts,
e.g. line breaks could be in different places etc. FlexReport always generates/lays out text like C1Report with
UseGdiPlusTextRendering set, but still there may be differences in line breaks between C1Report with UseGdiPlusTextRendering
set, and FlexReport.
The AddOutlineEntry event has been removed. To change the text of the outline entry generated by a field/section/sub-
section, use the OutlineLabel property.
A new specialized event type has been added for the C1FlexReport.ReportError event: ReportErrorEventHandler,
accepting ReportErrorEventArgs event arguments. The ReportEventArgs type has been modified - Exception and Handled have
been removed from the event arguments.
If a report contains Map custom field(s), it must be generated synchronously (call Render() rather than RenderAsync()), else the
map field cannot be displayed in the FlexViewer control. You should set the FlexViewer.UseAsyncRendering property to False.
In C1Report, EndReport event is not fired in case of an error. In FlexReport, the EndReport event is fired even if a fatal error
occurs during rendering.
C1Report.Document.Generate()
C1Report.Document.Export()
C1Report.Document.CreationDpi
C1Report.DocumentInternal
C1Report.Document.DoEvents
C1Report.Document.HasEditableTags
C1Report.CreationDevice
StartReport(), StartSection(), EndSection(), RenderField()
C1Report.DataSource.DataObject: In C1FlexReport, the same can be accessed through DataSource.Recordset property.
C1Report.EmfType: In C1FlexReport, use EMF+ instead.
C1Report.GetReportInfo(): In C1FlexReport, use C1FlexReport.ReportInfo instead.
C1Report.PageRenderingMode: In C1FlexReport, use C1FlexReport.GetPageImage in order to get a page’s metafile.
C1Report Render<X> method cannot be accessed in code behind with C1FlexReport. These methods are for internal use.
In FlexReport, IC1FlexReportRecordset does not have ApplyFilter() and ApplySort() methods. Instead, DataSource in
FlexReport has filters/sort definition, so these should be used. IC1FlexReportRecordset is assigned to DataSource.Recordset
while filters/sorts can be defined on the DataSource.
Use corresponding properties, same as used to be set for C1Report FieldBase object.
In FlexReport, instead of the AddScriptObject event there is GetScriptObject event. So in this case, instead of
this works:
c1flxr.GetScriptObject += c1flxr_GetScriptObject;
...
C1FlexReport caches rendered content and does not regenerate a report if the report template is not changed. To ensure that
report is regenerated, you can call C1FlexReport.SetDirty() method.
Key Features
The key features of FlexReport for WinForms are as follows:
Template applications ✓ ✓
that bind Report with
Viewer
Report Wizard
Report Wizard ✓ ✓ ✓ ✓
Report Styles
Columnar ✓
Tabular ✓ ✓ ✓ ✓
Justified ✓
Labels ✓ ✓
Stepped ✓
Outline ✓
Aligned ✓
Standard ✓
Form Letters ✓
OLAP ✓
Query Builder
Multiple reports in a ✓
report
Data Binding
MS SQL ✓ ✓ ✓
Server
Object ✓ ✓
Datasource
OLEDB ✓ ✓ ✓ ✓
SQLite ✓
Stored ✓ ✓
Procedure
XML ✓ ✓ ✓ ✓
Bind report ✓ ✓ ✓
to multiple
tables
Drag & ✓ ✓ ✓ ✓
drop
bound
fields to
report
DMX ✓ ✓
Microsoft ✓ ✓
Power
Pivot and
tabular
models
Microsoft ✓ ✓
Azure SQL
Database
SQL Server ✓ ✓
Parallel
Data
Warehouse
Oracle ✓ ✓
SAP ✓ ✓
NetWeaver
BI
Hyperion ✓ ✓
Essbase
Microsoft ✓ ✓
SharePoint
List
Teradata ✓ ✓
ODBC ✓ ✓ ✓
Access ✓ ✓ ✓ ✓
Excel ✓
ADO.NET ✓
Java Beans ✓
Salesforce ✓
OLAP ✓
SAP Table ✓
SAP BW ✓
Outlook ✓
Design Preview
Portrait/landscape ✓ ✓ ✓
control in preview
Viewers
HTML ✓ WebViewer
MVC ✓
UWP ✓
Windows ✓ ✓ ✓ ✓
WinForms ✓ ✓ ✓
WPF ✓ ✓ ✓
Web ✓ ✓
Report Features
Adding Sort ✓
Expressions
on Groups at
report level
Drillthrough ✓ ✓
Filtering ✓ ✓ ✓ ✓
Formatting ✓ ✓ ✓ ✓
controls -
Done
through tabs
and groups
of Ribbon
Grouping ✓ ✓ ✓ ✓
Hyperlinks ✓ ✓ ✓ ✓
ReportEvents ✓
Runtime ✓ ✓ ✓ ✓
Date & time
Sorting ✓ ✓ ✓ ✓
Summary ✓ ✓ ✓ ✓
Totals
Built-in ✓ ✓ ✓ ✓
Special
Fields
Report ✓
Scheduling
Adding Sort ✓ ✓ ✓
Expressions
on Groups
available on
Data
Regions
Subreports ✓ ✓ ✓ ✓
Interactive ✓ ✓ ✓ ✓
Sorting at
Runtime
Parameters
AllowBlank ✓ ✓ ✓
Parameters
Boolean ✓ ✓ ✓ ✓
DateTime ✓ ✓ ✓ ✓
Float ✓ ✓ ✓
Hidden Parameters ✓ ✓
Integer ✓ ✓ ✓
Multivalue ✓ ✓ ✓
Nullable ✓ ✓ ✓
Passing parameters ✓ ✓ ✓ ✓
to reports
String ✓ ✓ ✓ ✓
Date ✓ ✓
Currency ✓
Number ✓ ✓ ✓ ✓
Internal Parameters ✓
Options to refresh ✓ ✓ ✓ ✓
report with change in
Parameter values
Formats
Boolean ✓ ✓
Currency ✓ ✓ ✓ ✓
Date ✓ ✓ ✓ ✓
LongDate ✓ ✓ ✓ ✓
LongTime ✓ ✓ ✓ ✓
Number ✓ ✓ ✓ ✓
Percentage ✓ ✓ ✓ ✓
Short Date ✓ ✓ ✓ ✓
Short Time ✓ ✓ ✓ ✓
Time ✓ ✓ ✓ ✓
Decimal ✓ ✓ ✓
Full Date/time ✓ ✓ ✓
long
Full Date/time ✓ ✓ ✓
short
General ✓ ✓ ✓
General Date/time ✓ ✓ ✓
long
General Date/time ✓ ✓ ✓
short
Month day ✓ ✓ ✓
RFC1123 pattern ✓ ✓
Round trip ✓ ✓
Scientific ✓ ✓
Charts
2D 38 ✓ ✓ 33
3D 36 ✓ ✓ 7
Area ✓ ✓ ✓ ✓
Bar ✓ ✓ ✓ ✓
Column ✓ ✓ ✓ ✓
Cone ✓
Cylinder ✓ ✓ ✓
Doughnut ✓ ✓ ✓
Gantt ✓ ✓
Histogram ✓ ✓
Line ✓ ✓ ✓ ✓
Pie ✓ ✓ ✓ ✓
Polar ✓ ✓ ✓
Pyramid ✓ ✓ ✓
Radar ✓ ✓ ✓ ✓
Scatter ✓ ✓ ✓ ✓
Stacked ✓ ✓ ✓ ✓
Step ✓
Stock ✓ ✓ ✓ ✓
Bubble ✓ ✓ ✓
Candlestick ✓ ✓
Funnel ✓ ✓ ✓
Range ✓ ✓
Chart Wizards
Properties ✓ ✓
Export
Total Formats 14 3 7 10
BMP ✓
Excel (.xls) ✓ ✓
GIF ✓
HTML ✓
JPEG ✓
PDF ✓ ✓ ✓ ✓
PNG ✓
RTF ✓ ✓
TIFF ✓ ✓ ✓
Crystal Reports ✓
XML ✓
CSV ✓ ✓ ✓
MHTML ✓ ✓
Word (.doc) ✓ ✓ ✓
Import
C1Report ✓
ADP Reports ✓
MDB Reports ✓ ✓
Crystal Reports ✓ ✓
VB Script Editor ✓ ✓ ✓
Syntax check ✓ ✓ ✓ ✓
available
C# Editor ✓
Deployment Licensing
Royalty-free ✓ ✓
development
Sample Reports
Available for ✓ ✓
download
Medical Report ✓
Inventory ✓
Balance Sheet ✓ ✓
Budget Report ✓
Hospital Bills ✓
IntelliSense
Report Fields ✓
Database Fields ✓
Calculated Fields ✓
Parameters ✓
VB Script Functions ✓
Aggregates ✓
Associated Properties ✓
Property description ✓
Report Design
Add/insert resize ✓ ✓ ✓
actions for report
sections
Expand/Collapse ✓
buttons for
sections/subsections
Group header/footer ✓
Reorder ✓
Subsections ✓
Server Edition
FlexReport Dissection
Before starting with FlexReport, it is important to know about the components and controls that are shipped with
FlexReport, the object model of FlexReport, and sections or bands available in FlexReport. The following sections
provide indepth information about these.
C1FlexReport:
The C1FlexReport component is a report generating component that generates data-based banded reports.
You can render reports directly to a printer or preview control, or export to various portable formats (including
XLS, PDF, HTML, text, and images). The FlexReport component also exposes a rich object model for creating,
customizing, loading, and saving report definitions.
C1.Win.FlexViewer dll
It includes all viewing functionalities through following controls or components:
C1FlexViewer:
The FlexViewer control is a multiple document previewing control. It has a ribbon-based UI with all preview
related options (viewer pane and status bar) easily accessible.
C1FlexViewerPane:
The FlexViewerPane control displays the pages of the document being previewed, allows panning, zooming
and other preview operations. In the form designer, standard toolbars and status bar can be created on the
current form through context menu items.
C1FlexViewerDialog:
The FlexViewerDialog is a form that is displayed with the nested FlexViewer control.
Included Applications
In addition to the reporting components and controls, FlexReport also includes following stand-alone applications:
C1FlexReport Object
ReportName, Load, GetReportList, Save, Clear, Render, Parameters, Document, DoEvents, Cancel, Page,
MaxPages, Font, OnOpen, OnClose, OnNoData, OnPage, OnError, Evaluate, Execute
Layout Object
DataSource Object
DataSourceCollection
SortDefinition Object
Direction, Expression
SortDefinitionCollection
Owner, Report
CalculatedField Object
CalculatedFieldCollection
Owner, Report
Group
GroupCollection
ReportParameter Object
ReportParameterCollection
AllowedValuesDefinition Object
Section Object
SectionCollection
SubSection Object
SubSectionCollection
FieldBase Object
FieldCollection
BarCodeField Object
CheckBoxField Object
DataField Object
ImageField Object
RtfField Object
ShapeField Object
SubreportField Object
TextField Object
Format, Text
VisualReportObject
BehaviorOptions
Sections of FlexReport
Every report consists of the following five basic sections:
Section Description
Detail The Detail section contains fields that are rendered once for each record in the source
recordset.
Header The Report Header section is rendered at the beginning of the report.
Footer The Report Footer section is rendered at the end of the report.
Page Header The Page Header section is rendered at the top of every page (except optionally for pages
that contain the Report Header).
Page Footer The Page Footer section is rendered at the bottom of every page.
There are two additional sections for each group: a Group Header and a Group Footer Section. For example, a report
Note that sections can be made invisible, but they cannot be added or removed, except by adding or removing
groups.
The following diagram shows how each section is rendered on a typical report. It also displays how a sub-section in
the Detail section is rendered in the report:
Report Header
The first section rendered is the Report Header. This section usually contains information that identifies the report.
Page Header
After the Report Header comes the Page Header. If the report has no groups, this section usually contains labels that
describe the fields in the Detail Section.
Detail
The Detail section contains data for each record. It is possible to hide this section by setting its Visible property to
False, and display only Group Headers and Footers. This is a good way to create summary reports.
Page Footer
Report Footer
Finally, the Report Footer section is printed before the last page footer. This section is often used to display summary
information about the entire report.
Sub-section
The sub-section can be added to any section of a report; by default it gets added at the bottom of the section that is
currently selected. This section contains the additional data that enhances the data present in its parent section. A
section’s height is determined by the sum of heights of its sub-sections.
Customized sections
You can determine whether or not a section is visible by setting its Visible property to True or False. Group Headers
can be repeated at the top of every page (whether or not it is the beginning of a group) by setting their Repeat
property to True. Page Headers and Footers can be removed from pages that contain the Report Header and Footer
sections by setting the PageHeader and PageFooter properties on the Layout object.
The following steps will show you how to create a report definition, load the report into the C1FlexReport component,
and render the report.
You can create a new report definition in FlexReportDesigner using FlexReport Wizard. The FlexReport Wizard walks you
through the steps of creating a new report from start to finish. To begin, complete the following steps:
1. Run the C1FlexReportDesigner.exe file from the location discussed in About FlexReportDesigner.
2. Go to File Menu in the menu bar and select New command.
Blank space appears in the FlexReportdesigner to create a new report.
3. Click New Report drop down from the Reports tab located on the extreme left of designer and select Report
Wizard.
Click the Table option and select a table from the list.
Click the SQL option and type (or paste) an SQL statement into the editor.
Complete Step 1:
Complete the following steps:
1. Click the ellipses button to bring up the standard connection string builder. The Data Link Properties dialog
box opens.
2. Select the Provider tab and select a data provider from the list. For this example, select Microsoft Jet 4.0 OLE
DB Provider.
3. Click the Next button or select the Connection tab. Now you must choose a data source.
4. Click the ellipses button to select a database. The Select Access Database dialog box appears. For this
example, select the C1NWind.mdb located in the Common folder in the ComponentOne Samples directory
(by default installed in the Documents folder). Note that this directory reflects the default installation path and
its path may be different if you made changes to the installation path.
5. Click Open. You can test the connection and click OK.
6. Click OK to close the Data Link Properties dialog box.
7. Once you have selected your data source, you can select a table, view, or stored procedure to provide the
actual data. You can specify the DataSource.RecordSource string in two ways:
Select the Data source tab and select the Products table from the Tables list.
Select the SQL tab and type (or paste) an SQL statement into the editor.
For example:
8. Click Next. The wizard will walk you through the remaining steps.
1. With your mouse pointer, select the CategoryID field and drag it into the Groups list.
2. Press the >> button to move the remaining fields into the Detail list.
3. Click Next. The wizard will walk you through the remaining steps.
2. Click Next. The wizard will walk you through the remaining steps.
2. Click Next. The wizard will walk you through the remaining steps.
1. Enter a title for the new report, Products Report, for example.
You will notice that the report will require some adjustments.
You can invoke C1FlexReportDesigner from Visual Studio as well. To do so, complete the following steps:
1. Create a .NET project and add the C1FlexReport component to your Toolbox.
2. From the Toolbox, double-click the C1FlexReport icon to add the component to your project. Note that the
component will appear below the form in the Component Tray.
3. Click the C1FlexReport component's smart tag and select Edit Report from its Tasks menu.
The C1FlexReportDesigner opens and the C1FlexReport Wizard is ready to guide you through the five easy steps
discussed above.
The following steps show how you can create a report definition using the FlexReportDesigner application or using code.
You can even write your own report designer or ad-hoc report generator.
The example uses code to create a simple tabular report definition based on the C1NWind database. The code is commented
and illustrates the most important elements of the C1FlexReport object model. Complete the following steps:
1. First, add a button control, C1FlexReport component, and FlexViewer control to your form. Set the following
properties:
Button.Name = btnEmployees
C1FlexReport.Name = c1FlexReport1 (default name in C#)
C1FlexViewer.Name = c1FlexViewer1 (default name in C#)
2. Initialize the control, named c1FlexReport1, using the Clear method to clear its contents and set the control font (this
is the font that will be assigned to new fields):
Visual Basic
End Sub
C#
3. Next, set up the DataSource object to retrieve the data that you want from the C1NWind.mdb database. This is done
using the ConnectionString and RecordSource properties:
Visual Basic
C#
//initialize DataSource
DataSource ds = c1FlexReport1.DataSource;
ds.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\...\ComponentOne Samples\Common\C1NWind.mdb;";
ds.RecordSource = "Employees";
4. Next, initialize the Layout object that defines how the report will be laid out on the page. In this case, render the
report in Portrait mode and set its Width to 6.5 inches (8.5 page width minus one inch for margins on either side):
Visual Basic
'initialize Layout
Dim l As Layout = C1FlexReport1.Layout
l.Orientation = OrientationEnum.Portrait
l.Width = 6.5 * 1440 ' 8.5 - margins, in twips
C#
5. Now comes the interesting part. Every report has five basic sections: Detail, Report Header, Report Footer, Page
Header, and Page Footer. Use the following code to set up the report header by setting a couple of properties and
adding a title field to it:
Visual Basic
C#
The section object has a Fields collection. The collection's Add method creates a new field and assigns it to the
Section. The parameters specify the new field's Name, Text, Left, Top, Width, and Height properties. By default, the
field has the same font as the control. Since this is a title, it makes sense to change the font and make it larger. Note
that the field should be tall enough to accommodate the font size, or nothing will appear in it.
6. Next, set up the Page Footer Section. This section is more interesting because it contains expressions in the text fields.
To evaluate the expressions in the text field, simply set the expression in the TextField.Text.Expression property. The
expression in the text field is evaluated when the report is rendered. In C1Report, same is achieved by setting the
field's Calculated property to True. To create a page footer, add the following code:
VB
C#
The Page Footer section uses expressions with variables that are not intrinsic to VBScript, but are defined by
C1FlexReport.Page and Pages are variables that contain the current page number and the total page count. The
section also uses a field configured to look like a line.
7. Next, set up the Page Header Section. This section gets rendered at the top of every page and will display the field
labels. Using a Page Header section to display field labels is a common technique in tabular reports. The code is
simple, but looks a bit messy because of all the field measurements. In a real application, these values would not be
hard-wired into the program. To create a page header with field labels, add the following code:
Visual Basic
C#
This code illustrates a powerful technique for handling fonts. Since every field inherits the control font when it is
created, set the control's Font.Bold property to True before creating the fields, and set it back to False afterwards. As
a result, all controls in the Page Header section have a bold font.
8. To finalize the report, add the Detail Section. This is the section that shows the actual data. It contains expressions in
the text fields below each label in the Page Header Section. To create the Detail section, add the following code:
Visual Basic
textField1.Text.Expression = "FirstName"
textField1.Left = 500
textField1.Top = 0
textField1.Width = 900
textField1.Height = 300
C1FlexReport1.Sections.Detail.Fields.Add(textField1)
C#
textField1.Text.Expression = "FirstName";
textField1.Left = 500;
textField1.Top = 0;
textField1.Width = 900;
textField1.Height = 300;
c1FlexReport1.Sections.Detail.Fields.Add(textField1);
Note that all text fields contain expressions and each text field corresponds to the names of fields in the source record
source. Setting the expressions in the TextField.Text.Expression property ensures that the Text property is
interpreted as a database field name, as opposed to being rendered literally. It is important to adopt a naming
convention for report fields that makes them unique, different from recordset field names. If you had two fields
named "LastName", an expression such as "Left(LastName,1)" would be ambiguous. This example has adopted the
convention of beginning all report field names with "Fld".
Note that the "FldNotes" field has its AutoHeight property set to CanGrow, and a smaller font than the others. This
was done to make sure that the "Notes" field in the database, which contains a lot of text, will appear in the report.
Rather than make the field very tall and waste space, setting the AutoHeight property to CanGrow tells the control to
expand the field as needed to fit its contents; it also sets the containing section's AutoHeight property to True, so the
field doesn't spill off the Section.
9. The report definition is done. To render the report into the FlexViewer control, double-click the Employees button to
add an event handler for the btnEmployees_Click event. The Code Editor will open with the insertion point placed
Visual Basic
RenderEmployees()
C1FlexViewer1.DocumentSource = C1FlexReport1
C#
RenderEmployees();
c1FlexViewer1.DocumentSource = c1FlexReport1;
1. To resize the Group Header section, select its border and with your mouse pointer drag to the position where
you want it.
2. With your mouse pointer, drag the handles in the field corners to resize fields.
Tip: If text is not fitting in the field, set the Appearance.WordWrap property for the field to True in
the Properties window.
3. In the Properties window, select the UnitPriceCtl field in Detail section under the Unit Price column.
4. Set the Appearance.Format property for the field to Currency.
5. Click the Preview button to switch to Preview mode and see your modifications.
6. Click Design button to switch from Preview mode to Design mode.
7. Click the File menu and select Save As from the menu that appears.
8. In the Save Report Definition File dialog box, enter ProductsReport.flxr in the File name box. Save the file
to a location that you will remember for later use.
9. Close the Designer and return to your Visual Studio project.
You have successfully created a report definition file; in the next step you will load the report in the C1FlexReport
component.
Right-click the C1FlexReport component and select the Load Report menu option.
OR
Click the smart tag ( ) above the C1FlexReport component and select Load Report from the C1FlexReport
Tasks menu.
Using the Load Report dialog box to select the report you want, complete the following tasks:
In the next step you will render the report into a preview control.
1. From the Toolbox, double-click the C1FlexViewer control to add it to your project.
2. From the Properties window, set the C1FlexViewer.Dock property to Fill.
3. Select the Windows Form with your mouse and drag the corners to resize it.
4. Double-click the form and enter the following code in the Form1_Load event handler:
Visual Basic
C#
Design-Time Support
You can easily configure FlexReport for WinForms at design time using the property grid, menus, and designers in
Visual Studio. The following sections describe how to use design-time environment for configuring FlexReport and
FlexViewer.
Current Report:
Shows the name of the current report, specified in the ReportName property.
Load Report
Clicking Load Report opens the Load Report dialog box. For more information about loading a report, see
Load FlexReport at Design Time.
Edit Report
Clicking Edit Report opens the FlexReport Wizard if you have not already created a report definition or the
C1FlexReportDesigner if you have already created a report.
For more information on using the FlexReport Wizard, see Step 1 of 4: Creating a Report Definition. For
details on using the C1FlexReportDesigner, see Working with FlexReportDesigner.
Clear Report
Clears the report loaded in C1FlexReport. On clicking Clear Report, user is asked - 'Are you sure to clear Report
[Report Name]?'.
About
Clicking About displays the About dialog box, which is helpful in finding the version number of
C1.Win.FlexReport, as well as information about licensing and online resources.
Localize
Clicking Localize opens the Localize dialog box. In the Localize dialog box, you can customize your
localization settings.
About FlexViewer
Clicking About displays the control's About dialog box, which is helpful in finding the build version of the
control.
1. You start by creating a report using the FlexReportDesigner application to create report definitions; report
definitions are saved as .flxr files, and can be designed from scratch or imported from existing Microsoft Access
Reports and Crystal Reports. You can then modify the basic report using the designer.
2. The C1FlexReport component reads the report definitions and renders the reports using data from any
standard .NET data source.
3. The report definitions can be loaded at design time, and embedded in your application, or they can be read
and modified at run time. (You can even create report definitions from scratch, using the C1FlexReport object
model.)
4. Reports can be rendered directly to a printer, into a FlexViewer control, or exported to different formats.
The following diagram shows the relationship between the components in the FlexReport for WinForms package:
Note: Boxes with a bold border represent code components (controls and applications). Boxes with a thin
border represent files containing information (report definitions, data, and finished reports).
The following numbers refer to the numbered arrows in the image, indicating relationships between the components:
1. Use the C1FlexReportDesigner application to create, edit, and save FLXR report definition files.
2. The C1FlexReport component loads report definitions from the FLXR files created with the designer. This can
be done at design time (in this case the FLXR file is persisted with the control and not needed at run time) or at
run time using the Load method.
3. The C1FlexReport component loads data from the data source specified in the report definition file.
Alternatively, you can provide your own custom data source.
Note: To work with FlexReport the operating system must support NT 6.1 core. Therefore, the minimal system
requirements are Windows 7 SP1 or Windows Server 2008 R2 SP1 with Platform Update (KB2670838).
C1Document is similar to our WinForms’ C1Framework library. It is a set of rather low level utility classes used
by other components. Currently it is used by C1SsrsDocumentSource, C1SsrsViewer, and C1FlexReport.
C1DocumentSource: provides functionality to work with different documents and report types. It is a base
class to build C1Document objects. Its main functions are as follows:
Now C1SSRSDocumentSource.Generate() can be used immediately after defining all necessary properties like
DocumentLocation, ConnectionOptions, etc.
All GenerateXXX methods are now accessible only in C1SSRSDocumentSource; in C1DocumentSource these
// Summary:
// Describes the busy state of a C1DocumentSource object.
public enum C1DocumentSourceBusyState
{
// Summary:
// The document is ready (not busy).
Ready,
// Summary:
// The document is currently generating.
Generating,
// Summary:
// The document is currently exporting.
Exporting,
// Summary:
// The document is currently printing.
Printing,
}
The following properties can be used to determine the current state of the C1DocumentSource:
// Summary:
// Gets the value indicating whether the current C1DocumentSource busy.
public bool IsBusy { get; }
// Summary:
// Gets a value indicating whether this C1DocumentSource is disposed and can not be longer used.
public bool IsDisposed { get; }
The following events have been removed:
event EventHandler<ExecuteCustomActionCompletedEventArgs> ExecuteCustomActionCompleted;
event EventHandler<GetPageCompletedEventArgs> GetPageCompleted;
event EventHandler<GetLinkTargetPositionCompletedEventArgs> GetLinkTargetPositionCompleted;
event EventHandler PagesClear;
These methods validate the current parameter values and refresh their valid values lists if the values are valid.
Note that parameter values are now applied automatically when a report generation starts.
ConnectionString
RecordSource
Visual Basic
C#
//initialize DataSource
DataSource ds = c1FlexReport1.DataSource;
ds.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\...\ComponentOne Samples\Common\C1NWind.mdb;";
ds.RecordSource = "Employees";
If these properties are set, C1FlexReport initializes the data source and uses them to load the data from the database
automatically. This is same as initializing data source through the code or the designer as illustrated in Step 1 of 4:
Creating a Report Definition.
In Visual Studio by selecting Edit Report from the C1FlexReport context menu
In Visual Studio by selecting Edit Report from the C1FlexReport Tasks menu
From the C1FlexReportDesigner application, click the New Report button from the Reports tab
For more information on accessing the Edit Report link, see Design-Time Support.
Populating a report from a stored procedure is no different than using SQL statements or straight tables. In the first
screen of the C1FlexReport Wizard, click the ellipses button to choose a datasource. Then choose a Stored
Procedure from the list of available Data sources:
You can use the DataSource's ConnectionString and RecordSource properties to select the datasource:
In the Designer, use the DataSource dialog box to select the connection string (by clicking the ellipses button
"..."), then pick the table or sproc you want to use from the list. For example:
(In this case the stored procedure name has spaces, so it's enclosed in square brackets).
You can create the data source using whatever method you want, then assign it to the DataSource's Recordset
property:
This method requires you to write code, and is useful when you have your data cached somewhere and want to
use it to produce several reports. It overrides the previous method (if you specify ConnectionString,
RecordSource, and Recordset, C1FlexReport uses the Recordset).
The syntax is different depending on the type of connection/adapter you want to use (OleDb, SQL, Oracle, and
so on). The easier way to get the syntax right is to drag tables or sprocs from Visual Studio's Server Explorer
onto a form. This adds all the cryptic elements required, and then you can go over the code and pick up the
pieces you want.
You can specify stored procedures as data sources by their name. If the sproc has parameters, you pass them
Security restrictions dictate that connection strings must be kept private and only the data itself may be
exposed (not its source).
The database is not supported by OleDb (the provider used internally by C1FlexReport).
The data does not come from a database at all. Instead, the DataTable is created and populated using custom
code.
To use a DataTable object as a C1FlexReport data source, simply load the report definition and then assign the
DataTable to C1FlexReport.DataSource.Recordset property. For example:
Visual Basic
C#
Visual Basic
C#
Main data source: It is the main data source for a report. The main data source is specified by
using C1FlexReport.DataSourceName property on the report. If the main data source is not specified
(DataSourceName is empty or contains a name not found in the DataSources collection), C1FlexReport is
rendered in unbound mode, containing a single instance of the Detail section.
Data source for Parameters: It is the source of valid values for the report parameters (elements in
the C1FlexReport.Parameters collection). The data source for parameters is specified using
ReportParameter.AllowedValuesDefinition.Binding.DataSourceName property.
Data source for Charts: It is the data source for the Chart field. The data source for charts is specified using
ChartField.DataSource property.
OLE DB
ODBC
XML
Object in external assembly
Microsoft SQL Server Compact Data Provider version 3.5 and 4.0
For backwards compatibility with C1Report, C1FlexReport has a DataSource property which points to
DataSources[DataSourceName]. When a new C1FlexReport is created, a single element with the name 'Main' is added
to its C1FlexReport.DataSources collection, and 'Main' is assigned to the C1FlexReport.DataSourceName property.
Note that in C1Report, Main data source is the only data source for the report.
Visual Basic
C#
return report;
}
seriesTemplate.DataValues.AddNewValue("=Sum(UnitsInStock)"); // show
sum of UnitsInStock in AxisY.
return chart;
}
private ChartField CreateChartField(string name, string
datasource)
{
var chart = new ChartField
{
Name = name,
Width = 7500,
Height = 5000,
Top = 100,
Left = 100,
DataSource = datasource,
};
chart.Border.Color = Color.Black;
chart.Border.Width = 15;
chart.Border.Style = DashStyle.Solid;
chart.Border.CornerRadius = new CornerRadius(200d);
chart.ChartArea2D.AxisY.AutoMin = false;
return chart;
Visual Basic
C#
Visual Basic
C#
DataSource ds = c1FlexReport1.DataSources[0];
ds.CalculatedFields.Add(new CalculatedField("Calc1", typeof(int),
"CategoryID * 2"));
Note that if there are more than one Calculated field, they must have unique names.
1. Add one C1FlexReport component for each report definition you want to distribute. You may want to name
each control after the report it will render (this will make your code easier to maintain).
2. Right-click each C1FlexReport component and select the Load Report menu option to load report definitions
into each control. (You can also click the smart tag ( ) above the component to open the C1FlexReport Tasks
menu and choose the Load Report option.)
The Load Report dialog box appears, which allows you to select a report definition file and then a report
within that file.
To load a report, click the ellipses button to select the report definition file you created in Step 1, then select
the report from the drop-down list and click OK. The Load Report dialog box shows the name of the report
you selected and a count of groups, sections, and fields. This is what the dialog box looks like:
3. Add FlexViewer control to the form. Also, add a control that will allow the user to pick a report (this could be a
menu, a list box, or a group of buttons).
4. Add code to render the report selected by the user. For example, if you added a button in the previous step
with the name btnProductsReport, the code would look like this:
Visual Basic
C#
Note that rptProducts is the name of the C1FlexReport component that contains the report selected by the
user and c1FlexViewer1 is the name of the FlexViewer control.
Note: If the Edit Report command doesn't appear on the context menu and Properties window, it is probably
because the control could not find the C1FlexReportDesigner application. To fix this, simply run the
C1FlexReportDesigner application once in stand-alone mode. The designer will save its location to the registry,
and the C1FlexReport component should be able to find it afterwards.
The C1FlexReportDesigner application shows the report that is currently loaded in the C1FlexReport component. If
the C1FlexReport component is empty, the Designer shows the C1FlexReport Wizard so you can create a new report.
You can use the data source objects defined in your application as data sources for your new reports.
When you close the Designer, any changes you made will be saved back into the C1FlexReport component on
the form (unless you choose to discard the changes by selecting File | Exit from the Designer's menu, and
select No to saving the changes).
To use data source objects defined in your application, click the Data Source button in the Designer, then select the
Tables option in the Select a Data Source dialog box.
The Tables page shows a list of data objects currently defined on the form (the page will not be visible if there aren't
any valid data sources on the form). Alternatively, you can use the Connection string to build and select a connection
string and record source as usual.
For example, if the main form contains a DataSet object with several DataTables attached to it, the data source picker
dialog box might look like this:
Once you are done creating or editing the report, you can close the Designer by selecting File | Save and File | Exit
from the menu. This will save the report definition directly into the component (as if you had loaded it from a file
using the Load Report command).
If you change your mind and decide to cancel the changes, quit the Designer selecting File | Exit from the menu and
choose No to saving the changes.
1. Create all the required reports in the C1FlexReportDesigner application. For more information, see Working
Imports C1.Win.FlexReport
Imports System.IO
C#
using C1.Win.FlexReport;
using System.IO;
This allows you to reference the C1FlexReport and System.IO classes and objects without having to specify
the full namespaces.
4. Add the following code in the button click event to read the report definition file and build a list of all reports:
Visual Basic
' get application path
Dim appPath As String
appPath = Path.GetDirectoryName(Application.ExecutablePath).ToLower()
Dim i As Integer = appPath.IndexOf(vbBack & "in")
If (i < 0) Then
i = appPath.IndexOf(vbBack & "in")
End If
If (i > 0) Then
appPath = appPath.Remove(i, appPath.Length - i)
End If
' get names of reports in the report definition file
m_ReportDefinitionFile = appPath & Convert.ToString("\Data\Products Report.flxr")
Dim reports As String() = C1FlexReport.GetReportList(m_ReportDefinitionFile)
' populate combo box
cmbReport.Items.Clear()
The code starts by getting the location of the file that contains the report definitions. This is done using static
methods in the system-defined Path and Application classes. You may have to adjust the code to reflect the
location and name of your report definition file.
Then it uses the GetReportList method to retrieve an array containing the names of all reports in the report
definition file (created in step 1), and populates the combo box allowing users to select the report.
5. Add code to render the report selected by the user. For example:
Visual Basic
Try
Cursor = Cursors.WaitCursor
// load report
fv.StatusText = "Loading" + cmbReport.Text;
c1FlexReport1.Load(m_ReportDefinitionFile, cmbReport.Text);
Adding Parameters
Parameters are an important part of any report. They influence the data populated by manipulating the data passed
in the report. Parameters can be used for modifying the default values of data and applying filtering to the data. You
can also select more than one value using multi-value parameters.
Nullable Gets or sets a value indicating whether the value of this parameter can be Null. Cannot
be true if this is a multi-value parameter.
AllowBlank Gets or sets a value indicating whether the value of this parameter can be an empty
string. Ignored unless DataType is String.
MultiValue Gets or sets a value indicating whether this is a multivalue parameter (a parameter that
can take a set of values).
Hidden Gets or sets a value indicating whether the parameter should be hidden from the end
user (however, it will still be available for programmatic use with subreports, drill-
through reports etc.)
Prompt Gets or sets the prompt shown to the end user when prompting for parameter values.
Value Gets or sets the parameter value. Value can be specified as an array if MultiValue is true
(in this case all items should have the same item type).
AllowedValuesDefinition Gets AllowedValuesDefinition defining the list of allowed values for this parameter.
Allowed values can be specified as a static list using AllowedValuesDefinition.Values
property, or as a dynamic list bound to one of report’s data sources using
AllowedValuesDefinition.Binding property.
Report parameters can be easily added through the FlexReportDesigner application. For more information,
see Working with Parameters and Binding Data to Parameters in Multiple Data Source Report .
Grouping Data
Grouping is the most commonly used method to represent data in an organized manner. After designing the basic layout,
you may decide to segregate the records by certain fields, or other criteria that would make the report easier to read. By
grouping data, you can separate groups of records and display introductory and summary data for each group. The group
break is based on a grouping expression. This expression is usually based on one or more recordset fields but it can be as
complex as you want.
In FlexReport, grouping is achieved by using C1FlexReport.Groups.
Lets say you want to view a list of employees falling under a designation or title. In this case, the list should be grouped by
Title. The following steps illustrate how to Group the list of employees by the Title. This example uses sample created
in FlexReport Quick Start.
C#
Group grp;
Section s;
private void c1CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (groupC1CheckBox.Checked)
{
// group employees by title and sort titles in ascending
order
grp = c1FlexReport1.Groups.Add("GrpTitle", "Title",
SortEnum.Ascending);
// format the Header section for the new group
s = grp.SectionHeader;
s.Height = 1000;
s.Visible = true;
1. Add the following code in the check box event (c1CheckBox1_CheckedChanged) created in the
sample Grouping Data.
Visual Basic
C#
C#
Group grp2;
private void crossC1Button_Click(object sender, EventArgs e)
{
btnEmployees.PerformClick();
c1FlexReport1.Sections.Detail.Visible = false;
Sorting Data
Sorting is another way to organize data in ascending or descending order.
In FlexReport, sorting is achieved by using DataSource.SortDefinitions.
Lets say you want to view the list of employees with their names in ascending order. In this case the list should be sorted by
First Name. The following steps illustrate how to Sort the names of the list of employees in alphabetical order. This example
uses sample created in FlexReport Quick Start.
C#
Filtering Data
Filtering a data is important where you want to view only a portion of data based on certain criteria. In FlexReport, the
Visual Basic
C#
Run the project. You see that the First name, Last name, Title, and Notes for the employee with EmployeeID = 2 is
displayed.
With FlexViewer control, you can preview the reports as well as export them. The reports can be exported to several
file formats: .pdf, .html, .rtf, .docx, .xls, .xlsx, .zip, .tiff, .bmp, .png, .jpg, and .gif. The following code describes how to
export a FlexReport using Export method of C1FlexViewer Class:
Visual Basic
'Export
C1FlexViewer1.Export()
C#
//Export
c1FlexViewer1.Export();
The following code describes how to export a FlexReport to PDF using PdfFilter class. Similarly, you can also export
the report to other formats mentioned above.
Visual Basic
'Load a report
c1FlexReport1.Load("../../ProductsReport.flxr", "Products Report")
c1FlexReport1.Render()
'Give file name and path where exported file will be saved
filter.FileName = "Products Report" + "../../ProductsReport.pdf"
'The report is exported as ProductsReport.pdf in bin\debug folder
'Export
c1FlexReport1.RenderToFilter(filter)
C#
//Load a report
c1FlexReport1.Load(@"..\..\ProductsReport.flxr", "Products Report");
c1FlexReport1.Render();
//Give file name and path where exported file will be saved
filter.FileName = "Products Report" + @"..\..\ProductsReport.pdf";
//The report is exported as ProductsReport.pdf in bin\debug folder
//Export
c1FlexReport1.RenderToFilter(filter);
Expressions return values, you can assign them to things like Field.Text, for example:
Field1.Text.Expression = "iif( 1=1, 1+2, 1+3 )"
Statements don't return values. You can assign them to event properties like OnFormat. For example:
c1FlexReport.OnOpen = "if 1=1 then msgbox("OK!!!") else msgbox("ooops")"
C1FlexReport relies on VBScript to evaluate expressions in calculated fields and to handle report events.
VBScript is a full-featured language, and you have access to all its methods and functions when writing C1FlexReport
expressions. For the intrinsic features of the VBScript language, refer to the Microsoft Developer's Network (MSDN).
Global Scripts can be written in the new VBScript Editor. This editor allows users to define VBScript functions and
subroutines that are accessible throughout the report. To directly access the VBScript Editor, press F7 and to close the
editor and save the changes, use the shortcut key Ctrl+W. Users can switch between scripts and also change options
such as fonts or colors within the editor. The editor also makes the scripting experience intuitive and easy for
developers with advanced features such as syntax check, pre-defined VBScript functions, and rearranged scripting
functions.
To write global scripts using VBScript Editor option,
function Backcolor()
Detail.Backcolor=rgb(255,0,0)
end function
You can also write global scripts using GlobalScripts property of C1FlexReportDesigner as follows:
So, you have defined a global function 'Backcolor()', which can be used throughout the report.
The VBScript Editor has the following additional features:
IntelliSense: Provides auto code completion prompts for the scripts supported by VBScript Editor. IntelliSense
in VBScript Editor has following features:
The IntelliSense window that displays a context-dependent list of available words also displays a
detailed help on VBScript functions and keywords in a small tooltip or help window. The italic font on
the detailed help basically shows the category to which the current item belongs (such as 'VBScript
function', 'C1FlexReport aggregate script function', .NET object property, and so on).
On editing DataSource.Filter, the editor opens as Expression Editor - DataSource.Filter and
IntelliSense shows keywords or functions available in that with corresponding help.
Icons associated with IntelliSense entries indicate the type of the entry. The icons' color palette is
different for VBScript, report built-in stuff, and DataSource.Filter.
When a user types and Intellisense window is opened, the list is filtered according to the letters being
typed for example, typing 't' will only show words that contain the letter 't', typing 'te' will narrow the
list to words that contain 'te', and so on.
Backspace in the IntelliSense window undoes the last filter.
Pressing square bracket '[' shows the list of available db fields.
Pressing dot '.' after the name of an object such as a report, field, or section shows the .NET properties
available for that object
Pressing Ctrl+J, Ctrl+Space, or a letter after a non-letter character shows the list of available VBScript
functions, keywords, etc. depending on the context.
Note that Global Scripts dropdown in VBScript Editor is enabled only if you have previously defined global
script(s) in your report.
C1FlexReport extends VBScript by exposing additional objects, variables, and functions. These extensions are
described in the following sections.
Operators
Operator Description
And Performs a logical conjunction on two expressions.
Reserved symbols
The following table contains the VBScript reserved symbols and how to use them:
Keyword Description
True The True keyword has a value equal to -1.
Nothing Used to disassociate an object variable from any actual object. To assign
Nothing to an object variable, use the Set statement, for example: Set
MyObject = Nothing Several object variables can refer to the same actual
object. When Nothing is assigned to an object variable, that variable no longer
refers to any actual object. When several object variables refer to the same
object, memory and system resources associated with the object to which the
Null The Null keyword is used to indicate that a variable contains no valid data.
vbCr When you call print and display functions, you can use the following constants
in your code in place of the actual values.
vbCrLf When you call print and display functions, you can use the following constants
in your code in place of the actual values.
vbLf When you call print and display functions, you can use the following constants
in your code in place of the actual values.
vbFormFeed When you call print and display functions, you can use the following constants
in your code in place of the actual values.
vbNewLine When you call print and display functions, you can use the following constants
in your code in place of the actual values.
vbNullChar When you call print and display functions, you can use the following constants
in your code in place of the actual values.
vbTab When you call print and display functions, you can use the following constants
in your code in place of the actual values.
vbVerticalTab When you call print and display functions, you can use the following constants
in your code in place of the actual values.
Built-in functions
For more information on the VBScript functions, see the MSDN documentation.
The key features of VBScript that are part of C1FlexReport are as follows:
Built-in script functions, Like and In have functionality similar to SQL operators LIKE and IN and return True or False.
Like(str, template): Compares 'str' to 'template', which can contain wildcard '%'. Some examples of Like function are as
follows:
In(obj, obj1, ... objN): Tests whether 'obj' is among objects 'obj1', ... , 'objN'. Some examples of In function are as
follows:
As you can observe, both the functions are case-sensitive, so "abc" is not the same as "Abc".
Arrays
Select/Case statements
Statement keywords
Names of Field objects are evaluated and return a reference to the object, so you can access the field's properties. The
default property for the Field object is Value, so by itself the field name returns the field's current value. For example:
MyField.BackColor = RGB(200,250,100)
MyField.Font.Size = 14
MyField * 2 ' (same as MyField.Value * 2)
Note: If you give a report field the same name as a database field, you won't be able to access the report field.
Names of Section objects are evaluated and return a reference to the object, so you can access the section's
properties. The default property for the Section object is Name. For example:
If Page = 1 Then [Page Footer].Visible = False
Names of fields in the report's dataset source are evaluated and return the current field value. If a field name contains
spaces or periods, it must be enclosed in square brackets. For example:
OrderID
UnitsInStock
[Customer.FirstName]
[Name With Spaces]
Report Variables
Page
The page variable returns or sets the value of the Page property. This property is initialized by the control when it
starts rendering a report, and is incremented at each page break. You may reset it using code. For example:
Pages
The pages variable returns a token that gets replaced with the total page count when the report finishes rendering.
This is a read-only property that is typically used in page header or footer fields. For example:
"Page " & Page & " of " & Pages
Report Object
Cancel
Set Cancel to True to cancel the report rendering process. For example:
Format converts a value into a string formatted according to instructions contained in a format expression. The value
may be a number, Boolean, date, or string. The format is a string built using syntax similar to the format string used in
Visual Basic or VBA.
The following table describes the syntax used for the format string:
#,###.##0 Formats a number using a mask. The following symbols are recognized:
# digit placeholder 0 digit placeholder, force display , use thousand
separators ( enclose negative values in parenthesis % format as
percentage For example: Format(1234.1234, "#,###.##") =
"1,234.12"
Format(-1234, "#.00") = "(1234.12)"
Format(.1234, "#.##") = ".12"
Format(.1234, "0.##") = "0.12"
Format(.3, "#.##%") = "30.00%"
Currency Currency, $ Formats a number as a currency value. Displays number with thousand
separator, if appropriate; displays two digits to the right of the decimal
separator. For example: Format(1234, "$") = "$1,234.00"
q,m,d,w,yyyy Returns a date part (quarter, month, day of the month, week of the year,
year). For example: Format(#12/5/1#, "q") = "4"
String @@-@@/@@ Formats a string using a mask. The "@" character is a placeholder for a
@;Missing Uses the format string on the left of the semi-colon if the value is not
null or an empty string, otherwise returns the part on the right of the
semi-colon. For example: Format("@;Missing", "UK") = "UK"
Format("@;Missing", "") = "Missing"
Note that VBScript has its own built-in formatting functions (FormatNumber, FormatCurrency, FormatPercent,
FormatDateTime, and so on). You may use them instead of the VBA-style Format function described here.
Aggregate Functions
Aggregate functions are used to summarize data over the group being rendered. When used in a report header field,
these expressions return aggregates over the entire dataset. When used in group headers or footers, they return the
aggregate for the group.
All FlexReport aggregate functions take two arguments:
Function Description
Avg Average value of the expression within the current group. For
example, the following expression calculates the average sales
for the whole group and the average sales for a certain type of
product: Avg(SalesAmount)
Avg(SalesAmount, ProductType = 3)
Min, Max Minimum and maximum values for the expression. For example:
"Min Sale = " & Max(SaleAmount)
To use the aggregate functions, add a calculated field to a Header or Footer section, and assign the expression to the
field's Text property.
For example, the "Employee Sales by Country" report in the sample NWind.xml file contains several aggregate fields.
The report groups records by Country and by Employee.
The SalespersonTotal field in the Footer section of the Employee group contains the following expression:
=Sum([SaleAmount])
Because the field is in the Employee group footer, the expression returns the total sales for the current employee.
The CountryTotal and GrandTotal fields contain exactly the same expression. However, because these fields are in
the Country group footer and report footer, the expression returns the total sales for the current country and for the
entire recordset.
You may need to refer to a higher-level aggregate from within a group. For example, in the "Employee Sales by
Country" report, there is a field that shows sales in the current country as a percentage of the grand total. Since all
aggregates calculated within a country group refer to the current country, the report cannot calculate this directly.
Instead, the PercentOfGrandTotal field uses the following expression:
=[CountryTotal]/[GrandTotal]
CountryTotal and GrandTotal are fields located in the Country and Report Footer sections. Therefore, CountryTotal
holds the total for the current country and GrandTotal holds the total for the whole recordset.
It is important to realize that evaluating aggregate functions is time-consuming, since it requires the control to
traverse the recordset. Because of this, you should try to use aggregate functions in a few calculated fields only. Other
fields can then read the aggregate value directly from these fields, rather than evaluating the aggregate expression
again.
For example, the "Employee Sales by Country" report in the NorthWind database has a detail field,
PercentOfCountryTotal, that shows each sale as a percentage of the country's total sales. This field contains the
following expression:
=[SaleAmount]/[CountryTotal]
SaleAmount is a reference to a recordset field, which varies for each detail record. CountryTotal is a reference to a
report field that contains an aggregate function. When the control evaluates this expression, it gets the aggregate
value directly from the report field, and does not recalculate the aggregate.
For the complete report, see report "Employee Sales by Country" in the Nwind.xml report definition file, which is
available in the ComponentOne Samples folder.
Visual Studio
C#
OnClose Fired when the report finishes rendering. Can be used to perform clean-up
tasks.
OnNoData Fired when a report starts rendering but the source recordset is empty. You can
set the Cancel property to True to prevent the report from being generated.
You could also show a dialog box to alert the user as to the reason why no
OnPage Fired when a new page starts. Can be used to set the Visible property of
sections of fields depending on a set of conditions. The control maintains a
Page variable that is incremented automatically when a new page starts.
Section OnFormat Fired before the fields in a section are evaluated. At this point, the fields in the
source recordset reflect the values that will be rendered, but the report fields
do not.
OnPrint Fired before the fields in a section are printed. At this point, the fields have
already been evaluated and you can do conditional formatting.
To highlight products that are below the reorder level using code:
To highlight products that are below the reorder level by displaying their name in bold red characters, use an event
script that looks like this:
Visual Basic
C#
string script =
"if (UnitsInStock& ReorderLevel) then\r\n" +
"ProductNameCtl.ForeColor = rgb(255,0,0)\r\n" +
"ProductNameCtl.Font.Bold = true\r\n" +
"else\r\n" +
"ProductNameCtl.ForeColor = rgb(0,0,0)\r\n" +
"ProductNameCtl.Font.Bold = false\r\n" +
"end if\r\n";
c1FlexReport1.Sections.Detail.OnPrint = script;
1. Select Detail from the Properties window drop-down list in the Designer. This reveals the section's available
properties.
2. Click the empty box next to the Section.OnPrint property, then click the drop-down arrow, and select
Expression Editor from the list. VBScript Editor window appears.
3. In the VBScript Editor window, type the following script:
The control executes the VBScript code whenever the section is about to be printed. The script gets the value of the
"ReorderLevel" database field and sets the "ProductName" report field's Field.Font.Bold and Field.ForeColor
properties according to the value. If the product is below reorder level, its name becomes bold and red.
The following screen capture shows a section of the report with the special effects:
If isnull(PictureFieldName) Then
Detail.Visible = false
Else
Detail.Visible = true
End If
Visual Basic
C1FlexReport1.Sections.Detail.OnFormat = "Detail.Visible =
notisnull(PictureFieldName)"
C#
c1FlexReport1.Sections.Detail.OnFormat = "Detail.Visible =
notisnull(PictureFieldName)";
1. Select Detail from the Properties window drop-down list in the Designer. This reveals the section's available
properties.
2. Click the empty box next to the Section.OnFormat property, then click the drop-down arrow, and select
Expression Editor from the list. VBScript Editor window appears.
3. In the VBScript Editor:
Simply type the following script in the window:
If isnull(PictureFieldName) Then
Detail.Visible = false
Else
Detail.Visible = true
End If
Or you could use the more concise version:
Detail.Visible = not isnull(PictureFieldName)
To highlight products that are below the reorder level using code:
To highlight products that are below the reorder level by displaying a box, use an event script that looks like this:
Visual Basic
C#
string script =
"if (UnitsInStock < ReorderLevel) then\r\n" +
"BoxCtl.Visible = true\r\n" +
"else\r\n" +
"BoxCtl.Visible = false\r\n" +
"end if\r\n";
c1FlexReport1.Sections.Detail.OnPrint = script;
The code builds a string containing the VBScript event handler, and then assigns it to the section's OnPrint property.
1. Select Detail from the Properties window drop-down list in the Designer. This reveals the section's available
properties.
2. Click the ellipses next to the OnPrint property, to open VBScript Editor.
3. In the VBScript Editor, simply type the following script:
The following screen capture shows a section of the report with the special effects:
Using Code:
To reset the page counter when a group (for example, a new country) starts, set the PageFooter field's Text property.
Enter the following code:
Visual Basic
C#
Using FlexReportDesigner:
To reset the page counter when a group (for example, a new country) starts, set the PageFooter field's Text property
by completing the following steps:
1. Select the PageFooter's page number field from the Properties window drop-down list in the Designer or select
the field from the design pane. This reveals the field's available properties.
2. Click the box next to the Text property, then click the drop-down arrow, and select Expression Editor from the
list. VBScript Editor windows appears.
3. In the VBScript Editor, type the following script:
="Page " & GroupPage(0) & " of " & GroupPages(0) & " for " & Country
4. Click OK to close the editor.
Adding Sub-sections
Sub-sections are the additional sections that can be added to any section of a report. A FlexReport generally contains
- Detail, Header, Footer, PageHeader, Page Footer, Group Header and Group Footer - sections as described
in Sections of FlexReport.
Each of these sections contains atleast one sub-section, but you can add as many sub-sections in a section.
To add a sub-section in the Header section of a report, the following code should be used:
Visual Studio
C#
C1FlexReportDesigner.4.exe targets 'Any CPU' so the application runs in 64 bit mode on 64 bit systems and
in 32 bit mode on 32 bit systems. This application does not support use of 32 bit only data providers such as
Microsoft.Jet.OLEDB.4.0.
C1FlexReportDesigner32.4.exe targets x86 that allows using 32 bit only data providers such as
Microsoft.Jet.OLEDB.4.0.
You can create a basic report definition file, modify, print, and export the report definition. The following
topics explain all about the FlexReportDesigner application.
About FlexReportDesigner
The FlexReportDesigner application is a tool used for creating and editing C1FlexReport report definition files. The
Designer allows you to create, edit, load, and save files (FLXR) that can be read by the C1Report component. It also
allows you to import report definitions from Microsoft Access files (.mdb) and Crystal Reports (.rpt).
To run the Designer, double-click C1FlexReportDesigner.exe for 64 bit platform and
C1FlexReportDesigner32.4.exe for 32 bit platform located at the following location on your computer:
C:\Program Files (x86)\ComponentOne\Apps\v4.0
Note that this directory reflects the default installation path and its path may be different if you made changes to the
installation path.
Here's what the Designer looks like with the FlexCommonTasks.flxr file opened:
File menu: Contains information for handling report definition files - load, save, import and export.
Tabs - Home, Insert, Arrange, PageSetup - provide all functionalities related to a report definition
- editing, formatting, inserting fields and sections, positioning and sizing, and page layout and
printer settings.
Design mode: Provides shortcuts to the Edit, Text, Data, etc. menu functions. By default, Design
Mode is selected which consists of Home, Insert, Arrange, and Page Setup Tabs.
Preview mode: Provides a preview of the report. See Preview Mode for more information.
Reports tab: Lists all reports contained in the current report definition file. You can double-click a
report name to preview or edit the report. You can also use the list to rename, copy, and delete
reports.
Data tab: Lists all the Data Sources and Parameters in the current report. The data sources and
parameters can be added or edited from here.
Properties tab: Allows you to edit properties for the objects that are selected in the Designer.
Error tab: Displays list of errors, their severity and count, generated when importing or previewing a
report.
Status bar: Displays information about what the Designer is working on. If a field is selected, status
bar displays selected field's name, type, and if the field is data bound (calculated) or static. If a
section is selected, status bar displays the name of the section, section type, and its visibility if the
section is hidden. It also displays processes such as loading, saving, printing, rendering, importing,
and so on. You can zoom in and out of a selected report by dragging the zoom slider at the right of
the status bar.
Collapse/Expand Glyphs: Each section provides option to expand or collapse the sub-sections
contained within them by clicking expand ( ) or collapse ( )glyphs.
Database icon: Indicates that a field is bound to a data source (i.e., a calculated field), if the data
base icon appears on the top-right corner of the field. If the data base icon does not appear, it
means the field is static.
Snap Lines: Help in the alignment of the fields. When the size of a field is increased or decreased,
vertical and horizontal snap lines appear, that help in positioning the fields relative to each other.
Sub-sections: Sub-sections are sections within sections. Sub-sections, by default, appear at the
bottom of a section and are automatically named as /<B>, /<C>..., and so on.
Help button: Provides options to open the online help file and view the About screen, which
displays information about the application.
The topics that follow explain how you can use the C1FlexReportDesigner application to create, edit, use, and save
report definition files.
File Menu
The File menu provides shortcut to load and save report definition files and to import and export report definitions.
You can also access the C1FlexReportDesigner application's options through the File menu.
The following image displays the File menu:
Design Mode
In Design mode, sections and fields of the selected report are displayed. This is the main working area of the designer
where reports can be created or modified. The ribbon on the Design mode consists of the following tabs:
Home tab: Provides shortcuts to the Edit, Text, Border, Format, Data, and View menu functions. See Home Tab
Home Tab
Font: Displays the current font of the selected text and allows you to choose another font for the selected item (to do so,
click the drop-down arrow next to the font name).
Font Size: Displays the current font size of the selected text and allows you to choose another font size. Type a number in the
font size box or click the drop-down arrow to choose a font size.
Increase Font Size: Increases the font size by one point.
Decrease Font Size: Decreases the font size by one point.
Bold: Makes the selected text bold (you can also press CTRL+B).
Italic: Italicizes the selected text (you can also press CTRL+I).
Underline: Underlines the selected text (you can also press CTRL+U).
Align General: Aligns numbers to left and other values to right automatically.
Align Text Left: Aligns text to the left.
Center Text: Aligns text to the center.
Align Text Right: Aligns text to the right.
Justify Text: Justifies the selected text.
Font Color: Allows you to select the color of the selected text.
Fill Color: Allows you to select the background color of the selected text.
Border Line Style: Defines the style of the border lines of the currently selected field(s). The styles available are: Solid, Dash,
Dot, Dash-Dot, Dash-Dot-Dot, and Transparent.
Border Line Color: Defines the color of the border lines of the currently selected field(s).
Border Line Width: Defines the thickness of border line of the currently selected field(s) in twips.
Report Styles: Opens the Report Style Editor dialog box, where you can choose a built-in style or create and edit your own
custom style.
Format Painter: Applies style to the current selection.
As Table Row: Formats the current selection as a table row.
You can access the Report Style Editor dialog box by clicking Report Styles in the Format group.
Style Gallery List: Displays all the currently available built-in and custom styles. See Style Gallery for information about the
available built-in styles.
Add button: Adds a custom style to the Style Gallery list. The style that is added is based on the style selected in the Style
Gallery list when the Add button was clicked.
Remove button: Removes a selected custom style. The button is enabled only when a custom style is selected in the Style
Gallery list.
Property grid: Lets you change the properties and edit a custom style. The Property grid is only available and editable when
a custom style is selected in the Style Gallery list.
Preview window: Displays a preview of the style selected in the Style Gallery list.
Apply button: Applies the style to your selection without closing the dialog box.
OK button: Closes the dialog box, applies your changes, and sets the style as the current selected style.
Cancel button: Cancels any changes you have made to styles.
Data Sources: Clicking this button lists down the options Main and Add Data Source.
Main option lets you Edit or Remove the main data source to which the report is bound. Clicking Edit or Add Data Source
opens the Data Sources dialog box. You can then you to choose a new data source, change the connection string, and edit
the Sql statement. Clicking the drop down next to Data Source option displays the list of data sources present in the report.
From the Data source tab, you can select the tables, views, and stored procedures in the current data source. Clicking the Sql
statement tab allows you to view the current SQL statement:
To change the connection string, click the ellipses button. This will open the Data Link Properties dialog box. To edit or
change the SQL statement, click the Query builder... button which will open the Sql Builder dialog box.
Groups : Clicking this button opens the Groups dialog box where you can add and delete grouping and sorting criteria.
For more information see Grouping Data and Sorting Data.
Report Info : Opens the Report Information dialog box. This dialog box allows you to set the report's Title, Author,
Subject, Creator, and Keywords. You can also choose to apply report information to all reports.
VBScript Editor: Opens VBScript Editor - Report.GlobalScripts dialog box. Multiple scripts can be easily edited in the
VBScript Editor, allowing users to switch between statements and expressions.
Properties: Brings the Properties tab into view on the left pane. The shortcut key for viewing the Properties tab is F4.
Data: Brings the Data tab into view on the left pane. The shortcut key combination for viewing the Data tab is Shift+F4.
Error List: Displays the list of warnings and errors generated while importing or previewing a report.
Captions: Lets you make a choice of viewing captions for sections or sub-sections in the designer panel. You can choose
options - All (shows strip on all), Section (shows strip on Sections and not subsections), Hairline (hides the section header
strips), Hidden, Expand All and Collapse All options. The drop-down consists of the following options:
All
Section
Hidden
Expand
All
Collapse
All
Zoom: Allows you to select a value to set the zoom level of the report. You can also press Ctrl+Plus or Ctrl+Minus to zoom in
or zoom out the designer panel.
Insert Tab
Insert tab consists of several fields which can be inserted while designing a report. Each field button creates a field
and initializes its properties. The Insert tab consists of two groups:
Fields group: It consists of the following items:
SuperLabel: Creates a field that renders HTML formatted text. The text property of the field is set to any HTML
text that is required to be rendered.
Map: Creates a field that displays a region of earth, i.e., a map. See Maps in Reports for more information.
For more information on adding fields to your report, see Adding FlexReport Fields and Adding FlexReport Custom
Fields.
Arrange Tab
The Arrange tab provides shortcuts to grid, alignment, positioning , and sizing. It consists of the following groups.
Grid group: The Grid group consists of the following items:
Snap to Grid: Snaps fields to the grid. When this item is selected fields cannot be placed in between lines of
the grid.
Note that the elements in a report can be both horizontally and vertically aligned - so, for example, an element can be
both left and top aligned.
Position group: The Position group controls spacing between elements and how elements are layered. It consists of
the following items:
To Tallest: Sets the height of all selected fields to the tallest field.
To Shortest: Sets the height of all selected fields to the shortest field.
To Widest: Sets the width of all selected fields to the width of the widest field.
To Narrowest: Sets the width of all selected fields to the width of the narrowest field.
Size to Grid: Snaps the bounds of the selected fields to the nearest grid lines.
The Page Setup tab provides shortcuts to Page Layout menu functions. It consists of the following options:
Portrait: Changes the layout of your report to Portrait view (where the height is longer than the width).
Landscape: Changes the layout of your report to Landscape view (where the height is shorter than the width).
Page Setup: Opens the printer's Page Setup dialog box.
Preview Mode
The Preview mode displays preview of the current report. The ribbon on the Preview mode consists of the following
items:
Page Layout group: It consists of the following options:
Portrait: Changes the layout of your report to Portrait view (where the height is longer than the width).
Landscape: Changes the layout of your report to Landscape view (where the height is shorter than the width).
Page Setup: Opens the printer's Page Setup dialog box.
Hand Tool: The hand tool allows you to move the preview through a drag-and-drop operation.
Text Select Tool: The text select tool allows you to select text through a drag-and-drop operation. You can
then copy and paste this text to another application.
Find: Clicking the Find option opens the Find pane where you can search for text in the document. To find text
enter the text to find, choose search options (if any), and click Search.
Export Group: Each item in the Export group opens the Export Report to File dialog box where you can choose a
location for your exported file. The Export group consists of the following options:
PDF: Exports the report to a PDF file. The drop-down arrow includes options for PDF with non-embedded
(linked) fonts and PDF /A (embedded fonts) to choose if you want to use system fronts or embed your
chosen fonts in the PDF file.
HTML: Exports the report to an HTML file. You can then copy and paste this text to another application. The
drop-down arrow includes options for Plain HTML, Paged HTML, and Drilldown HTML, and Table-based
HTML allowing you to choose if you want to export to a plain HTML file, multiple HTML files that can be paged
using included arrow links.
Excel: Exports the report to a Microsoft Excel file. The drop-down arrow includes options for Microsoft Excel
Categorize property grid: Categorizes the Properties grid by property type. The Properties grid can be
accessed by clicking the Properties tab located in the bottom of the left pane in Design view.
Enable undo/redo: Enables undo and redo in the application.
Save/Load tab:
Reload last file on startup: If this option is checked, the last opened file will appear whenever the
C1FlexReportDesigner application is opened.
Save changes before rendering: Checking this option saves the report before rendering.
Show options when exporting: Checking this option saves the report's options when exporting.
Embed images into Xml when saving: Checking this option embeds images into XML when the report is
saved.
Default export format: Sets the default export format. For more information about exporting see Exporting
and Publishing a Report.
Connection tab:
Auto syntax checking: Determines if syntax is automatically checked in the VBScript Editor dialog box.
Syntax coloring: Determines if syntax text is automatically colored in the VBScript Editor dialog box.
Font: Defines the appearance of the text used in the VBScript Editor dialog box.
Warnings tab:
Check for updates on startup: Checking this option checks for any updates when C1FlexReportDesigner
application is opened.
Import from Crystal Reports: warn if RAS API is unavailable: Checking this option throws warning if RAS
API is unavailable while importing Crystal Reports in C1FlexReportDesigner.
In each of the above tabs, clicking OK saves the changes and clicking Cancel cancels any changes that you have made
in the FlexReportDesigner Options dialog box.
Style Gallery
The Style Gallery dialog box details all the available built-in and custom styles that you can use to format your report.
Built-in styles include standard Microsoft AutoFormat themes, including Vista and Office 2007 themes. You can access
the Style Gallery from the C1FlexReportDesigner application by selecting the Home tab and clicking Report Styles.
The following built-in styles are included:
Apex Paper
Aspect Solstice
Civic Technic
Concourse Trek
ComponentOne Urban
Equity Verve
Foundry Bold
Median Casual
Metro Compact
Module Corporate
None Formal
Opulent WebReport
Following steps let you add multiple sub-sections to Detail section of a report:
1. Click the Detail section. Observe that it already has a sub-section named Detail/ <A>.
2. Go to Insert Tab and click Add from the Subsection group. This adds one sub-section in the Detail section,
which is automatically named as Detail/ <B>.
3. Again click Add from the Subsection group to add one more sub-section. This adds another subsection named
as Detail/ <C>.
4. Go to Insert Tab and click Shape field from the Subsection group.
5. In the sub-section Detail/ <B>, drop the Shape field.
6. From the Properties window, set Shape property to Line. Drag the selection handle to increase or decrease
length of the line.
7. Preview the report.
You see a line is drawn after every field in the Detail section.
FlexChart Field
FlexReportDesigner provides a new field type, FlexChart field. The FlexChart field simplifies adding data visualization
capabilities to FlexReport using flexible data binding, multiple chart types, and supports grouping and data
aggregation. For more information on FlexChart, see FlexChart documentation.
- AccessibleName
- AccessibleRole
- AllowDrop
Anchor Anchor
AutoHeight -
AutoWidth AutoWidth
AxisX AxisX
AxisY AxisY
Background BackColor
- BackgroundImage
- BackgroundImageLayout
- Binding
- BindingX
Bookmark -
Border -
BodersPlitHorzMode -
BordersSplitVertMode -
- CausesValidation
CategoryGroups -
ChartType ChartType
- ContextMenuStrip
- Cursor
DataLabel DataLabel
- DataMember
- DataSource
- Dock
DataSourceName -
- Enabled
Font Font
Footer Footer
- ForeColor
ForcePageBreak -
- GenerateMember
Header Header
Height -
Hyperlink -
- ImeMode
Left -
Legend Legend
- LegendToggle
- Location
- Locked
- Margin
MarginBottom -
MarginLeft -
MarginTop -
- MaximumSize
- MinimumSize
- Modifiers
Options Options
OutlineLabel -
OutlineParent -
- Padding
Palette Palette
PlotMargin PlotMargin
PlotStyle PlotStyle
- RenderMode
RightToLeft RightToLeft
Rotated Rotated
- SelectedIndex
- SelectedMode
- SelectionStyle
Series Series
SeriesGroups -
- Size
- SmoothingMode
SplitHorzBehavior -
SplitVertBehavior -
Stacking Stacking
Tag -
- Text
- ToolTip
- ToolTip on ttCopy
Top -
Visible -
Width -
XLabelExpression -
- UseWaitCursor
Zorder -
FlexChartField FlexChart
AltStyle AltStyle
Binding
BindingMode
BindingX
ChartType ChartType
DataMember
DataSource
DataSourceName
Hyperlink
Label
Name
Style Style
SymbolMarker SymbolMarker
SymbolSize SymbolSize
SymbolStyle SymbolStyle
Visibility Visibility
XExpression
Y1Expression
Y2Expression
Y3Expression
YExpression
FlexChartField
CategoryGroups
FlexChart Series
SeriesGroups
SplineArea chart: A SplineArea Chart is similar to an area chart. The only difference is that it connects data points
using splines instead of straight lines and fills the area enclosed by the splines.
Bar chart: A Bar chart compares values across various categories or displays variations in a data series over time. It
represents data series in the form of bars of the same color and width, whose length is determined by its value. Each
Column chart: . A Column chart, just like the Bar Chart, represents variation in a data series over time or compares
different items. It displays values of one or more items as vertical bars against Y-axis and arranges items or categories
on X-axis.
Bubble Chart: A Bubble chart combines two independent values to supply both the point y value and the point sizes.
Bubble charts are used to represent an additional data value at each point by changing its size. The Y array elements
determine the Cartesian position (as in a XY-Plot chart), and the Y1 element values determine the size of the bubble at
each point. The size of the points can be encoded according to area or diameter.
Scatter chart: A Scatter chart uses two values to represent each data point. It depicts relationship among items of
different data series. This type of chart is often used to represent scientific data, and can highlight the deviation of
assembled data from predicted data or result.
Line chart: A Line chart displays trends over a period of time by connecting different data points in a series with a
straight line. It is the most effective way of denoting changes in the values between different groups of data.
LineSymbols chart: A LineSymbols chart is a combination of the Line chart and the Scatter chart. The chart plots data
points by using symbols and connects those data points by using lines.
Spline chart: A Spline chart is similar to a line chart except that it connects data points by using splines rather than
straight lines. It is specifically used for representing data that requires the use of curve fittings.
SplineSymbols: A SplineSymbols chart combines the Spline chart and the Scatter chart. The chart plots data points by
using symbols and connects those data points by using splines.
Funnel chart: A funnel chart represents sequential stages in a linear process. This chart can be useful in identifying
potential problem areas in processes where it is noticeable at what stages and rate the values decrease.
Stock Charts: Stock charts used in financial applications to show the opening, closing, high and low prices of a given
stock. The types of stock charts are as follows:
Candlestick chart: A Candlestick chart is a special type of HiLoOpenClose chart that integrates Bar and Line
charts to depict a range of values over time. It consists of visual elements known as candles that are further
comprised of three elements: body, wick, and tail. The body represents the opening and the closing value,
while the wick and the tail represent the highest and the lowest value respectively.
HiLoOpenClose: HiLoOpenClose charts combine four independent values to supply high, low, open, and close
data for a point in a series. In addition to showing the high and low value of a stock, the Y2 and Y3 array
elements represent the stock's opening and closing price, respectively.
To create a report showing grouping and aggregation of data in FlexChart, follow these steps.
1. In the C1FlexReportDesigner application, create a new report by navigating through the Report Wizard.
2. Bind the report to the Main data source, by specifying the following Sql Statement.
SELECT Categories.*, Categories.CategoryID as CategoryID, Products.* FROM
Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID
3. Add a SubSection to the Header section and add FlexChart field to it.
4. In the Properties window, expand AxisX and set the value of LabelAngle property to -10.
5. Navigate to AxisX|Style and set Font properties to Arial, 9pt, Regular, StrokeColor to Olive, and StrokeWidth
to 30.
6. Navigate to AxisY and set Font properties to Arial, 9pt, Regular, StrokeColor to Olive, and StrokeWidth to 15.
7. Set the Border Color to Black, Style to Solid and Width to 10.
8. Navigate to CategoryGroups and click ellipsis button next to it.
The DataGroup Collection Editor opens.
9. In the DataGroup Collection Editor, click Add button to add a data group and set it's GroupExpression to
CategoryID.
10. Close the Editor.
11. Navigate to Footer|Content and set it to Group By Category and Series.
12. Navigate to Header|Content and set it to Count of products per Category.
13. Navigate to Legend|Title and set it to Reorder Level.
14. Navigate to Series and click the ellipsis button next to it.
FlexChart Navigation
FlexChart field allows navigation to another report, a URL or script via the Hyperlink property of FlexChartField or a
particular Series.
Suppose you want to show Total Orders per Year and monthly sales for a particular year. Both these tasks can
be achieved in FlexReport using FlexChart navigation feature. In one report, the chart shows Total Orders per year and
in the other, the chart shows Sales per Month along with the total orders and amount received every month. If you
click on one series, the report navigates to the chart and pass the year for which Monthly sales are shown.
Let us create a report to navigate from a series to other report, or data within a report.
1. In the C1FlexReportDesigner application, create two new reports, Orders Report and Sales Report, by
navigating through the Report Wizard.
2. Bind the reports to the Main data source, by specifying the following Sql Statement.
SELECT o.OrderDate, od.Quantity * od.UnitPrice AS OrderItemSum FROM Orders AS o,
[Order Details] AS od WHERE o.OrderId = od.OrderId
3. Add a parameter, pYear, to the report and set it's DataType to Integer, Prompt to Year, and Value to 2012.
4. Add one FlexChart field in Orders Report and two FlexChart field in Sales Report.
5. Select FlexChart field in Orders Report.
6. In the Properties window, navigate to Series and click the ellipsis button next to it.
7. In the Series Collection Editor, click Add button to add a series data group, navigate to Data|YExpression and
set it's value to Sum(OrderItemSum).
8. Navigate to Hyperlink|LinkTarget and set it to Bookmark.
9. Click the ellipsis button next to the ParameterValues, add a parameter named pYear with =Year(OrderDate)
value, and close the ParametersValues Editor.
10. Set the Hyperlink|Report to Sales Report.
11. Close the Editor.
12. Navigate to SeriesGroups and click the ellipsis button next to it.
13. In the Data Group Collection Editor, click Add button to add a series and set it's GroupExpression to
Year(OrderDate).
14. Close the Editor.
15. Select the first FlexChart field in Sales Report.
16. In the Properties window, navigate to Series and click the ellipsis button next to it.
17. In the Series Collection Editor, click Add button to add a series data group.
18. Navigate to Hyperlink|LinkTarget and set it to Bookmark.
19. Set the Bookmark to =Month(OrderDate).
20. Close the Editor.
21. Navigate to SeriesGroups and click the ellipsis button next to it.
22. In the Data Group Collection Editor, click Add button to add a series and set it's GroupExpression to
Month(OrderDate).
23. Close the Editor.
24. Select the second FlexChart field in Sales Report.
Text Field
The Text field is the most commonly used report field to display data. It is used to insert:
5. Add the 'CategoryName' data field to the group header section of the report.
Rtf Field
The Rich Text Formatted (RTF) field is used to display a formatted text. When you click this button, a menu appears
where you can select other fields that are contained in the same report definition file to be displayed in RTF format.
These are data-bound RTF fields.
RTF fields are particularly used in creating Mail Merge reports.
To create a mail merge using RTF field in FlexReportDesigner application:
Paragraph Field
In order to use multi formatted text, Database fields, scripts, Parameters, Calculated Fields within a single Field, Paragraph
field is the best option for you. In edit mode, you can implement following features through Paragraph field:
1. In edit mode, right-click the Paragraph field and select Insert Expression.
2. In the Expression editor, select 'ProductID' from DatabaseFields dropdown.
3. Click Done.
4. Select "Product:{ProductID}" and set Forecolor as Green from the Ribbon.
To insert scripts:
Checkbox Field
The Checkbox field is used to add a visual for Yes or No. The checkbox field, by default, appears as an empty box with the
text on the right. It takes the boolean value; if it evaluates to true, a check mark appears in the check box.
To add data bound check box in FlexReportDesigner application:
Barcode Field
Barcodes in FlexReport let you integrate several industry-standard barcodes in Barcode field, that can be quickly and
easily generated in your reports. Simply drop the barcode field on your report, select the barcode symbology, provide
the text, and you are done!
The functionality of barcodes in FlexReport further extended by properties associated with them. The checksums to
the value being encoded are automatically added to eliminate reader errors.
Barcode Symbology
Barcode symbology specifies the encoding scheme used to convert character data into the pattern of wide and
narrow bars and spaces in a barcode. The following table illustrates the barcode symbology used in FlexReport.
You can directly insert a barcode field in the FlexReportDesigner using the BarCode property in the Properties
window. You can also use Barcode to set the type of BarCode in the barcode field.
Note that the following barcodes support FNC1 characters:
EAN128FNC1
MicroPDF417
RSSExpanded
RSSExpandedStacked
Barcode Properties
The BarcodeOptions provides additional properties for rendering barcodes in FlexReport. Following are the
common properties exposed by BarcodeOptions:
BarDirection: Lets you select the barcode's direction, horizontally or vertically. The available options are
LeftToRight, RightToLeft, TopToBottom, and BottomToTop. The direction of barcode can also be
set using BarDirectionEnum.
CaptionGrouping: Lets you split the text of the caption into groups for the barcode types it supports. Its value
is either True or False.
CaptionPosition: Lets you select the caption's vertical position relative to the barcode symbol. The available
options are None, Above, and Below.
CheckSumEnabled: Determines whether a checksum of the barcode will be computed and included in the
barcode when applicable.
TextAlign: Lets you select the caption text alignment. The available options are Left, Center, and Right.
SupplementNumber: Lets you specify the supplement for the barcode data, supplement is 2 or 5 digit for EAN
or UPC symbologies.
SizeOptions:
BarHeight: Specifies the height of a barcode in twips.
ModuleSize: Specifies the module (narrowest bar width) of a barcode in twips.
NarrowWideRatio: Specifies the ratio between the width of narrow and wide bars.
SizeMode: Specifies the sizing mode of a barcode. The options available are:
Other options exposed by BarcodeOptions corresponding to different barcode styles are as follows:
Code49:
Grouping: Lets you use grouping in the barcode. Its value is either True or False.
Group: Obtains or sets group numbers for barcode grouping. Its value is between 0 and 8.
DataMatrix:
EccMode: Lets you select the ECC mode. The possible values are ECC000, ECC050, ECC080, ECC100, ECC140, or
ECC200.
Ecc200SymbolSize: Lets you select the size of the ECC200 symbol. The default value is SquareAuto.
Ecc200EncodingMode: Lets you select the ECC200 encoding mode. The possible values are Auto, ASCII, C40,
Text, X12, EDIFACT, or Base256.
Ecc000_140SymbolSize: Lets you select the size of the ECC000_140 symbol.
StructuredAppend: Lets you select whether the current barcode symbol is part of structured append symbols.
StructureNumber: Lets you specify the structure number of the current symbol within the structured append
symbols.
FileIdentifier: Lets you specify the file identifier of a related group of structured append symbols. The valid file
indentifier value should be within [1,254]. Setting file identifier to 0 lets the file identifier be calculated
automatically.
GS1Composite:
Type: Lets you select the composite symbol type. Its value can be None or CCA. CCA (Composite Component -
Version A) is the smallest variant of the 2-dimensional composite component.
Value: Gets or sets the CCA character data.
MicroPDF417:
CompactionMode: Lets you select the type of CompactionMode. The possible values are Auto,
TextCompactionMode, NumericCompactionMode, or ByteCompactionMode.
FileID: Lets you specify the file id of the structured append symbol. It takes the value from 0 to 899.
SegmentCount: Lets you specify the segment count of the structured append symbol. It takes the value from 0
to 99999.
SegmentIndex: Lets you specify the segment index of the structured append symbol. It takes the value from 0
to 99998 and less than the value of segment count.
Version: Lets you select the symbol size. The default value is ColumnPriorAuto.
PDF417:
Column: Lets you specify the column numbers for the barcode.
Row: Lets you specify the row numbers for the barcode.
ErrorLevel: Lets you specify the error correction level for the barcode.
Type: Lets you select the type of PDF417 barcode. The available types are Normal and Simple.
QRCode
Model: Lets you select the model of QRCode. The available models are Model1 and Model2.
ErrorLevel: Lets you select the error correction level for the barcode. The available options are Low, Medium,
Quality, and High.
Version: Lets you specify the version of the barcode.
Mask: Lets you select the pattern used for masking barcode. In order to make sure QRCode being successfully
read, mask process is required to balance brightness. The options available are Auto, Mask000, Mask001,
RssExpandedStacked:
The quiet zones for barcodes can be specified easily by using MarginBottom, MarginLeft, MarginRight, and
MarginTop properties in the Property pane of the C1FlexReportDesigner.
Calculated Field
In order to create fields that do not use raw data, Calculated fields are the best option. Calculated fields contain
expressions that are evaluated at run-time. They are used to generate those data values that are not stored in the data
base.
Some predefined expressions are available in the dropdown of Calculated Fields.
To add a predefined Calculated field using FlexReportDesigner application:
To define a Calculated field and add the field in the FlexReportDesigner application:
Quantity*UnitPrice
Image Field
Image field is used to insert images that are data-dound or static. On clicking Image field, a dialog box appears
that prompts you to select an image file to be inserted in the report. A copy of the image you select is made and
placed in the same directory as the report file. You must distribute this file with the application unless you embed the
report file in the application. When you embed a report file in your application, any unbound picture files are
embedded too.
To add a Image field using FlexReportDesigner application:
Shape Field
Shape fields are used to display geometric shapes in reports. Lines are often used as separators, rectangles are used
to highlight groups of fields or to create tables and grids, and so on.
You can also set rules for defining visibility of a shape in the expressions. For example, if you want Product names to
be enclosed in a rectangular shape when the Reorder Level is less than the Units in Stock, you can write following
expression in the OnPrint property of the report, to define when to turn on the visibility of shape:
This scenario is discussed in detail in the topic Showing or Hiding a Field Depending on a Value.
Subreport Field
Subreport fields are used to insert subreports in a report. Subreports are regular reports contained in a field in another
report (the main report). Subreports are usually designed to display detail information based on a current value in the main
report, in a master-detail scenario.
In the following example, the main report contains categories and the subreport in the Detail section contains product details
for the current category:
To create a master-detail report based on the Categories and Products tables, you need to create a Categories report
(master view) and a Products report (details view).
1. From the Reports list in the Designer, select Categories Report (master report).
2. In design mode, from Fields group in Insert tab, click the Subreport icon and select Products Report from the drop-
down menu.
3. In the Detail section of your report, click and drag the mouse pointer to make the field for the subreport:
1. Right-click the subreport field and select Link Subreport from the menu.
Link Subreport dialog box appears that allows you to select which fields should be linked.
2. Once you make a selection and click OK, the Report Designer builds the link expression and assigns it to the
Chart Types
The Chart Field in FlexReport allows you to insert various types of charts using Chart.Chart2DGroup.ChartType and
Chart.Chart3DGroup.ChartType. The chart types that are supported in C1FlexReport are - Area, Bar (horizontal
bars), Column (vertical columns), Doughnut, Scatter (X-Y values), Line, Pie, Step, Stock, Histogram, Radar, Polar, and 3D
charts-Cone, Cylinder, and Pyramid. The chart types can be easily selected using the ChartType property in
the Properties window of the C1FlexReportDesigner.
Area chart: An Area chart draws each series as connected points of data, filled below the points. Each series is drawn
on top of the preceding series.
Bar and Column charts: A Bar chart or a Column chart represents each series in the form of bars of the same color
and width, whose length is determined by its value. Each new series is plotted in the form of bars next to the bars of
the preceding series. A Bar or Column chart draws each series as a bar in a cluster. The number of clusters is the
number of points in the data. Each cluster displays the nth data point in each series. When the bars are arranged
horizontally, the chart is called a bar chart and when the bars are arranged vertically, the chart is called column chart.
The following image represents a Bar chart:
Bubble Chart: A Bubble chart combines two independent values to supply both the point y value and the point sizes.
Bubble charts are used to represent an additional data value at each point by changing its size. The Y array elements
determine the Cartesian position (as in a XY-Plot chart), and the Y1 element values determine the size of the bubble at
each point. The size of the points can be encoded according to area or diameter.
Scatter chart: A Scatter chart uses two values to represent each data point. This type of chart is often used to support
statistical techniques that quantify the relationship between the variables (typically Linear Regression Analysis).
Pie chart: A Pie chart draws each series as a slice in a pie. The number of pies is the number of points in the data.
Each pie displays the nth data point in each series. You can also customize Pie charts for displaying legends and
labels.
Doughnut Chart:
A doughnut chart is a pie chart with a non-zero radius and is identical in function to a pie chart, but can be used to
increase aesthetic appeal, particularly when shown with 3D effects. As with all pie charts, each doughnut shows each
series as a fraction of the whole at each data point. If multiple data points are specified, then multiple doughnuts
appear in the chart.
A doughnut chart can be created by setting the InnerRadius property of a pie chart to a non-zero value. The
InnerRadius value represents the percentage of the full pie radius. The InnerRadius property can be accessed in the
pie object of each Chart group.
Radar chart: A Radar chart draws the y value in each data set along a radar line (the x value is ignored except for
labels). If the data has n unique points, then the chart plane is divided into n equal angle segments, and a radar line is
drawn (representing each point) at n/360 degree increments. By default, the radar line representing the first point is
drawn vertically (at 90 degrees). Radar charts can be further customized.
Line chart: A Line chart draws each series as connected points of data. It is the most effective way of denoting
changes in values between different groups of data. These charts are commonly used to show trends and
performance over time.
Stock Charts: Stock charts used in financial applications to show the opening, closing, high and low prices of a given
stock. The types of stock charts are as follows:
Candle: A Candle chart is a special type of HiLoOpenClose chart that is used to show the relationship between
the open and close as well as the high and low. Like, HiLoOpenClose charts, Candle charts use the same price
data (high, low, open, and close values) except they include a thick candle-like body that uses the color and
size of the body to reveal additional information about the relationship between the open and close values. For
example, long transparent candles show buying pressure and long filled candles show selling pressure.
The Candle chart is made up of the following elements: candle, wick, and tail. The candle or the body (the solid
bar between the opening and closing values) represents the change in stock price from opening to closing. The
thin lines, wick and tail, above and below the candle depict the high/low range. A hollow candle or transparent
candle indicates a rising stock price (close was higher than open). In a hollow candle, the bottom of the body
represents the opening price and the top of the body represents the closing price. A filled candle indicates a
falling stock price (open was higher than close). In a filled candle the top of the body represents the opening
price and the bottom of the body represents the closing price.
C1Chart creates the Candle chart with using the Y value for the High, Y1 for the low, Y2 for the open, and Y3 for
the close. C1Chart automatically fills the falling candle with the value of the line color.
HiLo: A HiLo chart combines two independent values to supply high and low data for each point in a series.
HiLo charts are used primarily in financial applications to show the high and low price for a given stock. The
elements of the Y and Y1 arrays in each series of a HiLo chart represent the "high" value, and the "low" value.
HiLoOpenClose: HiLoOpenClose charts are similar to HiLo charts except that they combine four independent
values to supply high, low, open, and close data for a point in a series. In addition to showing the high and low
value of a stock, the Y2 and Y3 array elements represent the stock's opening and closing price, respectively.
Histogram chart: A Histogram chart takes a collection of raw data values and plots the frequency distribution. It is
frequently used with grouped data, which is generated by measuring a collection of raw data and plotting the number
of data values that fall within defined intervals. Note that raw values are not used to generate data for a histogram,
but are used to generate a frequency instead. While showing similarities to bar charts, it is important to note that
histograms are used with quantitative variables whereas bar charts are commonly used with qualitative variables.
While the histogram and bar charts' appearances relate, their functionality does not. A bar chart is created from data
points whereas a Histogram is created from the frequency distribution of the data. The charts following illustrate the
difference between a bar chart and a histogram chart. Both of the charts use exactly the same Y data. The bar chart
(top) shows each average mean temperature for each year in which it occurred. The histogram chart (bottom) using
the same input temperature data automatically tabulates the number of temperatures that fall within each interval
and draws the resulting histogram. For convenience, chart labels with the count in each interval have been added at
the top of each interval.
A histogram is beneficial for pinpointing prominent features of the distribution of data for a quantitative variable. The
important features for a quantitative variable include the following:
To select the chart type as Histogram, go to ChartGroups|Group0 and set the ChartType to Histogram.
Polar chart: A Polar chart draws the x and y coordinates in each series as (theta,r), where theta is amount of rotation
from the origin and r is the distance from the origin. Theta may be specified in either degrees (default) or radians.
Since the X-axis is a circle, the X-axis maximum and minimum values are fixed. The series can be drawn independently,
or stacked.
3D Charts
Cylinder chart: A Cylinder chart is a variation of the Bar and Column charts. It represents the bars or columns
as cylinders. The Cylinder chart creates long circular boxes of the same base on both ends. Like all bar and
column charts, the Cylinder bar chart is appropriate for comparing individual items or groups of items.
Cone chart: A Cone chart is a variation of the 3D Bar and Column charts. It represents the bars or columns as
cones. The cone chart essentially is a rotated triangle. It has a flat circular base and one curved side topped by
a higher point.
Pyramid chart: A Pyramid chart is a variation the 3D-Bar and Column charts. It represents the bars or columns
as pyramids. The Pyramid chart is similar to the cone chart except for their base. Pyramid charts are often used
for geographical purposes.
Chart Properties
Chart Data Source
Chart Visual Effects
These editors can be invoked by right-clicking the chart field and selecting the required editor.
Chart Properties
It provides an easy and interactive way to create and modify a new or existing chart. It contains the options to select
the type of chart and . However, it also includes additional property settings for the x and y axis along with
appearance settings for the header, footer, legend, chart area, and plot area of the chart. The Chart Properties dialog
box provides more options to address specific details with the design of the chart you are developing. It consists of
following elements:
Gallery Item: The Gallery item in the left pane of the Chart Properties dialog box provides options for
choosing a chart type and/or a sub-type of a chart. To see a description of all chart type selections, see Chart
Types. You can choose from a variety of simple chart types or you could click on complex types to add more
functionality to your chart.
Simple Types Tab: In the Simple Types tab you can choose from one of many simple chart types and then you
can select a specialized chart located in list box next to the simple chart types.
Complex Types Tab: In the Complex Types tab you can specify whether you want to chart one or two chart
groups. Also, you can select the type of chart you would like to create in the drop-down box for each group.
For each group, you have the option to make the groups stacked and/or 3D.
Note: If you don't select a chart type for data [Group1] then the elements for data [Group1] will not appear in
the list box in the left pane of the Chart Properties dialog box.
The Chart Data editor lets you bind the chart by setting data through Chart Data-add or remove data series in your
chart, specify the label and color of each data series, and stack your data by checking the Show stacked data check
box.
Visual Effects is a tool used for visually enhancing the Chart2D control's elements such as the data series, header, and
footer. Any existing project can use the new features provided by this tool. The chart's appearance can dramatically
improve in a few simple steps using the Visual Effects designer.
The collection editors for Chart field are as follows:
ValueLabel Collection Editor: This collection editor can be assessed through the Property
pane-ChartArea|AxisX|ValueLabels. For more information, see the documentation on ValueLabel
CollectionEditor.
ChartDataSeries Collection Editor: This collection editor can be assessed through the Property
pane-ChartGroups|Group0|ChartData|CategoryGroups. For more information, see the documentation on
ChartDataSeries CollectionEditor.
ChartLabel Collection Editor: This collection editor can be assessed through the Property
pane-ChartLabels|DefaultLabelStyle|LabelsCollection. For more information, see the documentation on
LabelCollection Editor.
ChartVisualEffectsStyle Collection Editor: This collection editor can be assessed through the Property
pane-VisualEffects|Styles. For more information, see the documentation on VisualEffectsStyle Collection
Editor.
For example, the chart shown is created using C1NWind.mdb database and Products table, with following properties
set:
1. Go to Properties window.
2. Select Titles|Header, set the header text as 'Header' and Titles|Header|Visible to True.
3. Select Titles|Footer, set the footer text as 'Footer' to add header and footer to the chart.
You can also add axis titles in the chart, add back color and border to chart area, and more. For more information on
using properties for customizing charts, see 2DChart documentation.
Three dimensional data can be represented in the form of 3D Surface, 3D Bar, and many more by using 3D Chart
types. To plot 3D charts from 2D charts, you can change the VisualizationType property to Chart3D. For more
information on plotting 3D charts, see 3DChart documentation.
1. In the C1FlexReportDesigner application, create a new report by navigating through the C1FlexReport
wizard or open an existing report definition.
2. Add Chart field to the Detail section.
Note: To add Legacy Chart field to your report, you need to add it to the INSERT tab. In order to do
that, go to File|Options in the designer and select Show "Legacy Chart" button on the INSERT tab.
3. In Properties window, expand ChartGroups|Group0|ChartType and select a type of chart from the
ChartType dropdown. In our case, we have selected Bar chart type.
4. Navigate to ChartGroups|Group0|ChartData and click the ellipsis button next to UnboundSeriesList
property.
5. In the ChartUnboundDataSeries Collection Editor, add any number of series you want to plot in chart. Here,
we have added two series.
6. Select one of the series and click the ellipsis button next to SeriesData property.
7. In the editor for series data, enter your data.
8. Click OK to close the editors.
9. Click the Preview button to switch to Preview mode to view the report.
Sometimes you need to create charts that have multiple data sets or multiple series. To create such charts, the values
for each series are required to be set.
To create Legend:
Detail section
Continuing with the example mentioned above, lets visualize the report data for each category through chart.
Add a Legacy Chart field to the Group Header section (Category Name) and create the chart as explained in the
topic Plotting Data in Charts. Specify X and Y values of the chart as ProductName and UnitPrice and specify Value in
Series Values as UnitPrice.
The images below show screenshots of the report described above with the group headers, the charts they contain,
and a few detail records to illustrate:
The chart above shows unit prices for products in the "Condiments" category. The chart below shows unit prices for
products in the "Confections" category.
For registering a custom field, say MyField, add your control to the <customfields> section in the
C1FlexReportDesigner.4.exe.settings file as follows:
<customfields>
<!-- THIS LINE ADDS A NEW FIELD TO THE DESIGNER -->
<item value="MyCustomFieldAssembly;MyCustomFieldAssembly.MyField" />
</customfields>
Note that the code above assumes that your field is called "MyField" and it can be found in the assembly called
"MyCustomFieldAssembly". Also, MyCustomFieldAssembly should be in the same folder as the designer.
Following are built-in standard custom fields that are loaded in the FlexReportDesigner application by default:
SuperLabel
Maps
Note that if C1FlexReport definition contains map field and the report is generated asynchronously, the map
field cannot be displayed in the FlexViewer control. As a workaround please set
the C1FlexViewer.UseAsyncRendering property to False.
The main part of a map is the tile layer which provides raster graphics representing the Earth surface or part of it, and
zero or more layers representing spatial data.
The tile layer is specified by the TileSource property. It may be set to a VirtualEarth tile source (road, aerial, or hybrid).
The tile source may be set to "none" in which case no tiles will be drawn on the map. This may be useful especially
when other layers such as KML provide enough data for the map visualization.
Note that unless the tile source is "none", the tiles are loaded from a network location when the report runs, which
may slow things down considerably.
Except for the tile layer, all other layers are contained in the Layers collection. Currently, three layer types are
supported as described below:
Points Layer: A points layer allows to show spatial data as points on the map. A marker is drawn for each
record of the data source. A marker's location is specified either by a Longitude/Latitude pair, or by a
MapLocation, as described in Spatial Locations. The following points describe important aspects of the points
layer.
Tracking
The map shown by a Map field can automatically center and zoom in on the data shown on the map. This behavior is
determined by two factors:
The AutoCenter and AutoZoom properties' values specified for the whole Map field, together with several
related properties fine-tuning the automatic centering and zooming (AutoZoomPadLon, AutoZoomPadLat,
MaxAutoZoom, RoundAutoZoom).
The spatial data represented by the layers, provided that data is "tracked". Tracking (such as whether or not a
particular piece of spatial data should be used for automatic centering and zooming) is determined by the
layer's Track property. Additionally, for KML layers an expression may be specified which will determine
whether a specific KML item should be tracked or not.
Styles
Visual attributes of map elements are mostly defined by styles. There are several types of styles (point marker
styles, line styles and KML item styles); the applicable type is determined by the context, such as points layers use
point marker styles, lines layers use line styles, and so on. Usually a style may be specified as a data driven
expression (so that the actual style depends on run time data), with a fallback style used by default. How style
expressions are specified and evaluated is described next.
MarkerStyles
LineStyles
KmlItemStyles
These styles are available to all layers defined on the Map, and also to other Map fields in the current report. The
styles in each collection are addressable either by index or - preferably - by name (using the Name property). When a
style expression evaluates to a string, that string is used to search for a matching style, first in the current map and if
that fails, in all other maps on the current report (only matching type styles are searched; for example, only
MarkerStyles collections are searched for a point marker style, and so on).
Spatial Locations
Points and lines layers provide two different ways to specify spatial locations for the data:
As a pair of expressions that evaluate to a longitude/latitude pair at run time. Typically these would directly
reference corresponding data fields (longitude and latitude) stored in the data source.
As a MapLocation, an expression (or a list of expressions) that evaluates to a string that can be used to retrieve
the corresponding spatial location using an external online service (Google Maps). If the specified
MapLocation contains semicolons, it is treated as a list of semicolon-delimited expressions, each of which is
evaluated separately and then combined to use as the query. A typical MapLocation could look like this:
"Address;City;PostalCode;Country"
which would fetch Address, City, PostalCode, and Country fields from the data source and then combine them
to query the external service.
Note that using MapLocation may be very time consuming due to Internet access. Hence by default the
retrieved spatial data is stored in a local disk file. The path to that file is specified by the Map.GeoCachePath
property. By default the file's name is "geocache.xml", and it is stored in the same directory as the report
definition. Disabling geocaching is not recommended.
A map can have several associated legends, rendered within its bounds. To facilitate placing a legend outside the
map's bounds, the legend can be associated with any map field in the report, so you can add an empty map field just
to hold a legend describing another map.
Legends are contained within the Legends collection of the Map field. To add a legend, add an item to that
collection. The location of a legend within its map's bounds is determined by the LegendAlignment property.
Orientation determines whether items within the legend are placed vertically (default) or horizontally. Several other
properties allow to fine-tune the way the legend looks.
Items within the legend are represented by the Items collection. That collection may be populated automatically with
data from non-KML layers of the current map, if the Automatic property of the legend is set to True. In that case the
Items collection cannot be edited. Otherwise, the legend items must be added manually.
The following types of legend items are supported:
LegendLayerStyleItem: represents a layer style. The designer allows to select an existing layer or style
represented by the legend item. Depending on the selected layer style, the legend item may represent a point
marker (for points layers/styles), a line (for line layers/styles) or a color swatch (for KML item styles).
LegendColorSwatchItem: represents an arbitrary color swatch.
LegendTextItem: represents arbitrary text.
Add a new report in the designer, with C1NWind.mdb as the data source, with the following SQL query:
Customers and Suppliers by City
Make some room for the map by dragging the header's bottom edge down in the report designer.
Click on the Map custom field icon and drag it onto the header.
Set the map's properties as follows (only non-defaults are shown here):
AutoCenter: False
AutoZoom: False
CenterLatitude: 10
CenterLongitude: 15
ShowScale: True
TileSource: VirtualEarthAriel
ZoomLevel: .55
4. Add Layers.
Click ellipsis button next to Layers collection to open LayerBase Collection Editor. Add Members 'Employees',
Suppliers', and 'Customers', select the data source and set their marker style and map location properties.
Note that you need to add a data source every time before you add a member to the LayerBase Collection
Editor as each member uses different data source.
The design area looks like the following image:
SuperLabel.Text
<html><body><font color="Red">Customers and Suppliers by City</font></body>
</html>
Data binding
Creating expressions for calculated fields
5. Right-click Parameters and select Add Parameter from the context menu.
6. Set the properties of parameters from the Properties window depending upon the task that needs to be
accomplished using parameters.
The following sections explain the various tasks that can be achieved using parameters.
Data Binding
To perform data binding in report parameters, the steps are as follows:
5. Select a Data Source, say DataSource1, to create a new data source and set Connection, Data provider,
Connection string, etc.
6. You can rename DataSource1 from the Properties window by setting Name property. In our case, we
have set Name to dsCategories.
7. Add a parameter by right-clicking Parameters and then selecting Add Parameter.
8. From the Properties window, click the ellipses button next to AllowedValuesDefinition. The
AllowedValuesDefinition Editor dialog box appears.
9. Select the From Data Source radio button and then select Data Source, Label, and Value for binding the data
source to the parameter as shown. Click OK.
10. From the Properties window, set the DataType to a value that is same as the data type of Value in the
AllowedValuesDefinition Editor. In our case, DataType is set to Integer since Value=CategoryID is integer.
Calculated Fields
14. Preview the report. Select the product name from Parameter0 and enter the discount value in Discount parameter.
The discounted price is calculated on clicking Apply Parameters.
Subreports
Subreports are useful in displaying additional information about the data present in the main report. Just as you pass
parameters to a report, you can also pass parameters to subreports and create connection between the data values in
subreports.
For instance, you want to fetch data in subreports that are rendered side by side on a main report. The steps to attain such a
scenario are as follows.
14. Similarly, set the Name - prmPlace and Value - prmRightPlace.Value for Subreport field on the right. In the design
view the report should look similar to the following:
You can see two parameter prompts with a list of values (i.e. places), one for each subreport. Select the values and click
Apply Parameters. Here, we have selected Chaumont for left subreport and Cote d'Azur for right subreport.
Cascading Parameters
Cascading parameters are used when a list of values in one parameter depends on the value selected for the other
parameter. So you have two parameters, where one parameter alters the data source used to list data values for another
1. Create a new report. Bind the report to Order Details available in C1NWind.mdb.
2. Add two Data Sources, one for each parameter:
dsCategory to pass values to parameter prmCategory
dsProduct to pass values to parameter prmProduct
3. Right-click dsCategories and select Edit to edit the data source. Set Data provider, Connection string, and write
following Sql Statement:
4. Repeat the previous step for dsProducts. Write the following Sql Statement:
5. Right-click Main data source, select Edit and write Sql Statement for Main data source:
On selecting a category, a list of products available in that category are displayed in the other parameter. You can then select
the product and then click Apply Parameters. Here, we have displayed data in Aniseed Syrup product that falls in the
Condiments category.
Multi-value Parameters
Multi-value parameters are parameter collection that allows you to pass multiple values for a parameter; that is, you
can select multiple data from a list of data.
In FlexReportDesigner application, a parameter can be made multi-value by setting Parameter.MultiValue to True.
On previewing a report with multi-value parameter, a list of values bound to the parameter is displayed. You can then
select the values that you want to be rendered in the report.
Or
4. Data Sources dialog box appears. From the drop-down next to Data Source option, select DataSource1,
DataSource2, and so on for adding as many data sources. You can later on rename these data sources from the
Name property of the data source(s).
Or
4. The Data Sources dialog box opens. Select the new data source, change the connection string, and edit the Sql
statement, and you are done.
1. Create a new report - Products Report - bound to Main data source through C1NWind.mdb. Select Product
Name, Quantity Per Unit, and Stock as the text and calculated fields, so that the report appears as shown:
2. To view the report where data is sorted by Product Name, go to Design mode.
3. Click Data tab.
4. Expand Data Sources node.
5. Expand the Main data source to which the report is bound.
6. Right-click Sort Definitions.
For previewing the report, click Preview or press shortcut key F5.
For printing the report, go to File menu and click Print or press shortcut keys Ctrl+P. Note that the Print
option is enabled only in Preview mode. The Print dialog box lets you specify the settings on the printer.
You can also edit the page settings through the options available in the Page Layout group
To import reports, click the File menu and select Import from the menu. A dialog box prompts you for the name of
the file you want to import.
The dialog box also allows you to specify if the Designer should clear all currently defined reports before starting the import process.
Note that importing Microsoft Access report requires Access to be installed on the computer. Once the report is imported into
the Designer, Access is no longer required.
The import process handles most elements of the source reports, with a few exceptions:
Access reports can use VBA, macros and forms to format the report dynamically. C1FlexReport can do the same things, but it
only uses VBScript. Because of this, all report code needs to be translated manually.
These limitations affect a relatively small number of reports, but you should preview all reports after importing them, to make sure
they still work correctly.
To illustrate how the Designer fares in a real-life example, try importing the C1NWind.mdb file. It contains the following 13 reports.
(The NWind.xml file that ships with C1FlexReport already contains all the following modifications.)
No action required.
2. Catalog
No action required.
3. Customer Labels
No action required.
This report contains code which needs to be translated manually. The following code should be assigned to the Group 1
Header OnPrint property:
To write code in Visual Basic
Visual Basic
If SalespersonTotal > 5000 Then
ExceededGoalLabel.Visible = True
SalespersonLine.Visible = True
Else
ExceededGoalLabel.Visible = False
SalespersonLine.Visible = False
End If
To write code in C#
C#
if (SalespersonTotal > 5000)
{
ExceededGoalLabel.Visible = true;
SalespersonLine.Visible = true;
5. Invoice
No action required.
6. Products by Category
No action required.
7. Sales by Category
This report contains a Chart control that is not imported. To add a chart to your report, you can use the Chart field.
9. Sales by Year
This report contains code and references to a Form object which need to be translated manually. To replace the Form object
in the Data panel, add a "ShowDetails" parameter. Set its DataType property to Boolean and Value property to False:
Use the new parameter in the report's OnOpen event:
To write code in Visual Basic
Visual Basic
Dim script As String = _
"bDetails = [Show Details]" & vbCrLf & _
"Detail.Visible = bDetails" & vbCrLf & _
"[Group 0 Footer].Visible = bDetails" & vbCrLf & _
"DetailsLabel.Visible = bDetails" & vbCrLf & _
"LineNumberLabel2.Visible = bDetails" & vbCrLf & _
"Line15.Visible = bDetails" & vbCrLf & _
"SalesLabel2.Visible = bDetails" & vbCrLf & _
"OrdersShippedLabel2.Visible = bDetails" & vbCrLf & _
"ShippedDateLabel2.Visible = bDetails" & vbCrLf & _
"Line10.Visible = bDetails"
C1FlexReport1.Sections.Detail.OnPrint = script
To write code in C#
C#
string script = "bDetails = [Show Details]" +
"Detail.Visible = bDetails\r\n" +
"[Group 0 Footer].Visible = bDetails\r\n" +
"DetailsLabel.Visible = bDetails\r\n" +
"LineNumberLabel2.Visible = bDetails\r\n" +
"Line15.Visible = bDetails\r\n" +
"SalesLabel2.Visible = bDetails\r\n" +
"OrdersShippedLabel2.Visible = bDetails\r\n" +
"ShippedDateLabel2.Visible = bDetails\r\n" +
"Line10.Visible = bDetails";
c1FlexReport1.Sections.Detail.OnPrint = script;
To write code in C#
C#
Sections ("Detail").OnPrint =
"PageHeader.Visible = true";
Sections("Group 0 Footer).OnPrint =
"PageHeader.Visible = false";
Visual Basic
PageTotal = 0
To write code in C#
C#
PageTotal = 0;
Visual Basic
PageTotal = PageTotal + SaleAmount
HiddenPageBreak.Visible = (Counter = 10)
To write code in C#
C#
PageTotal = PageTotal + SaleAmount;
HiddenPageBreak.Visible = (Counter = 10);
Summing up the information on the table, out of the 13 reports imported from the NorthWind database: nine did not require any
editing, three required some code translation, and one had a chart control that required adding a Chart field.
1. Click the File menu and select Import. The Import Report Definition dialog box opens and prompts you for
the name of the file you want to import.
2. Select a Crystal report definition file (.rpt). The FlexReportDesigner application converts the report into the
FlexReport format.
3. Save the report. Your Crystal Report is now converted to FlexReport.
Reports bound to internal or external data sources can be imported and run without any changes required to the
original data source path.
The FlexReportDesigner application supports the following conversions on import of Crystal Reports:
Sections/SubSections
Report Header
Page Header
Group Header
Detail
Group Footer
Page Footer
Report Footer
Fields
Textbox
Chart
Box
Line
Picture
Checkbox
Subreport (needs manual correction of path)
Image Fields - BLOBField (Picture) OLEObject (Picture)
Database Field
Cross-section box control
Special Fields
Time Formats
Page Numbers
Features
Formatting
Text Formatting
Note: Before you import the report, please ensure that you have Crystal Reports version 13.0.14.xxxx or later.
This version of Crystal Reports should be compatible with Visual Studio installed on your system. Also note that
The import process handles most elements of the source reports, with a few exceptions for elements that are not
exposed by the Crystal object model or not supported by C1FlexReport. The conversions that are not yet supported in
C1FlexReportDesigner application are as follows, however, these features are expected to be incorporated in
upcoming 2016 releases.
Format Description
Paged HTML (*.html) Creates one HTML file for each page in the report. The HTML pages contain links that
let the user navigate the report.
Plain HTML (*.html) Creates a single HTML file with no drill-down functionality.
PDF with non-embedded Creates a PDF file that can be viewed on any computer equipped with Adobe's Acrobat
(linked) fonts (*.pdf) viewer or browser plug-ins.
PDF/A with embedded Creates a PDF file with embedded font information for extra portability.
fonts (*.pdf)
RTF (*.rtf) Creates an RTF file that can be opened by most popular word processors (for example,
Microsoft Word, WordPad). It can be saved as Paged or Open XML document.
Microsoft Excel 97 (*.xls) Creates an XLS file that can be opened by Microsoft Excel.
Microsoft Excel 2007/2010 Creates an XLS file that can be opened by Microsoft Excel 2007 and later.
Open XML (*.xlsx)
Open XML Word (*.docx) Creates a DOCX file that can be opened by Microsoft Word 2007 and later.
Compressed Metafile (*.zip) Creates a compressed metafile file, of the type EmfOnly, EmfPlusOnly,and EmfPlusDual.
TIFF (*.tiff), BMP, PNG, JPEG, Create image file of type TIFF (Tag Image File Format), BMP (Bitmap Images),
GIF images PNG(Portable Network Graphic), JPEG or GIF.
To create an export file, select File | Export from the menu and use the Export Report to File dialog box to specify
the location, File name and Save as type.
Export to PDF/A
A FlexReport can be exported to a PDF format that is in compliance with the PDF/A standards.
PDF/A is commonly used for creating invoices, brochures, manuals or research reports, and storing the reports in
6. Fill the dialog box and then click OK. Your exported PDF/A document opens in the PDF reader installed on your
computer.
You have successfully exported your report that is in compliance with the PDF/A standards!
Background
Setting a Background color using FlexReportDesigner is quiet easy. A background color in FlexReport can be set for
3. Select a color for the background. You can choose color from the tabs - Web, System, Custom, and Gradient.
4. Preview the report.
5. You can also set Gradient - Linear or Radial - for the background. For obtaining a Gradient, switch to Design
mode.
6. Select the Header section of the report.
7. From the Properties window, click the drop-down next to Background property. Go to Gradient tab and edit
the settings from the options available as shown:
8. Specify the gradient as Linear. You can also drag the slider to change the start and stop for the gradient.
9. Preview the report. The Report Header now looks as follows:
Border
In FlexReportDesigner, you can easily set Borders for Fields, Sections, and Sub-sections.
To set Border around Fields/Section
3. Select the Line Style and Line Width; select Borders to show - All or - any one or the combination of Left,
Top, Right, or Bottom borders. Select the color and click OK.
4. Lets insert borders with rounded corners in the Report Header. Select the Report Header.
5. Set the Line Style, Line Width, Borders, and color as before.
6. Set the Radius X and Radius Y for the corners.
7. Preview the report.
User-friendly UI
FlexViewer has an interactive and user friendly full-featured modern Ribbon-based UI that helps preview
different document types such as FlexReport, SSRS, and PDF document. The ribbon contains command buttons
clustered in groups.
Use/Reset Parameters
With FlexViewer, you can view parameters and reset them as well. You can in enter data parameters of your
choice to display a report. FlexViewer supports String, Boolean, Date, Integer, and Float type parameters.
Refresh and Stop Rendering
FlexViewer provides you options to Refresh and Cancel Report rendering through Refresh and Stop button.
View Thumbnails and Hierarchy
FlexViewer allows you to view the thumbnails of the report pages and the hierarchy in the outlines that allows
you to jump to a required location.
Page Navigation
Page navigation is available in the Navigation group of the FlexViewer control, which contains a set of
command buttons allowing you can navigate through the report pages and if you want to jump to a specific
FlexViewer Toolbar
The FlexViewer toolbar appears on the top of the control as shown in the image below:
It consists of the following shortcut command buttons at the top of the toolbar:
All the command buttons are divided in groups in FlexViewer toolbar as listed below:
Zoom, Actual Size, Page Width,Whole Allows you to open Zoom dialog box
Page using Zoom button. Actual Size allows
you to zoom the page to 100% of the
normal size, Page Width allows you to
zoom pages to fill the window width,
and Whole page allows you to zoom
pages to fit within the window
Print, Export, Find, HandTool, Allows you to print and export reports.
TextSelect Tool, Copy Text Find button allows you to find text in
the report, Hand Tool allows you to
scroll in window using the mouse, Text
Select Tool selects text to copy, and
Copy Text button allows you to copy
the selected text
You can rotate the view of reports in FlexViewer at design time by performing the following steps:
To rotate view of a report, at first you need to create and load a report and then preview it in the FlexViewer control.
After doing so, you can use FlexViewerRotateView enum to rotate view of a report. The following code illustrates the
Visual Basic
c1FlexViewer1.RotateView = FlexViewerRotateView.Rotation90Clockwise
C#
c1FlexViewer1.RotateView = FlexViewerRotateView.Rotation90Clockwise;
1. From the Toolbox, double-click the FlexViewer control to add it to your project.
2. From the Properties window, set the C1FlexViewer.Dock property to Fill.
3. Select the Windows Form with your mouse and drag to resize it. For this example, we resized the Form to
600x500 so it better reveals the preview panel.
4. Double-click the form and enter the following code in the Form_Load event handler:
C#
FlexReport Samples
With the C1Studio installer, you get FlexReport samples that help you understand the implementation of the product.
The C# and VB samples are available at the default installation folder -
\Documents\ComponentOneSamples\Winforms\C1FlexReport.
The list of available C# samples is as follows:
Sample Description
AddScriptObject This sample demonstrates how to add custom objects to C1FlexReport's script engine.
AdHocSorting This sample demonstrates how to select the sorting criteria before rendering the report.
FlexCommonTasks This sample demonstrates how to use parameters, charts, subreports, and many other
features in FlexReport. It uses FlexCommonTasks.flxr file.
FlexReport Explorer This sample loads a categorized list of reports, with categories such as enterprise, financial,
medical and so on. Some reports demonstrate specific features of FlexReport, such as
conditional formatting or watermarks, while others combine various features to produce
reports that might be used in different real-life applications.
MapReports The sample renders and previews several sample reports demonstrating the Map custom
field.
ODataRecordset This sample demonstrates how to use data provided by the OData service in the
C1FlexReport.
PdfViewer This sample shows how the C1PdfDocumentSource component can be used with
C1FlexViewer to view PDF document.
SsrsViewer This sample demonstrates how C1SSRSDocumentSource component can be used with
C1FlexViewer to browse the reports tree available on a SSRS server, and to preview
individual reports.
SubReportDataSource This sample demonstrates how to use custom data sources with subreports in
the C1FlexReport component.
Xml2FlxrConverter This sample allows the user to select one or more .XML files containing C1Report report
definitions, and to convert them to the new FlexReport's .FLXR file format.
ZipReport This sample demonstrates how to compress and encrypt report definition files using the
C1FlexReport and C1Zip components.
Sample Description
FlexReport Explorer This sample loads a categorized list of reports, with categories such as enterprise, financial,
medical and so on. Some reports demonstrate specific features of FlexReport, such as
conditional formatting or watermarks, while others combine various features to produce
reports that might be used in different real-life applications.
SsrsViewer This sample demonstrates how C1SSRSDocumentSource component can be used with
C1FlexViewer to browse the reports tree available on a SSRS server, and to preview individual
reports.
Note: For the complete report, see report 'Alternating Background' in the FlexCommonTasks.flxr report
definition file, which is available in the ComponentOne
Samples\Winforms\C1FlexReport\CS\FlexCommonTasks folder. The data base used is C1NWind.mdb which
is also available in the ComponentOne Samples folder.
pCondition pHighlightColor
Values Label -Unit price greater than 50, Value - CInt(1) Label - Red, Value - Red
Label -Unit price greater than 100, Value - CInt(2) Label - Green, Value - Green
7. In Design mode, select Detail from the drop-down list above the Properties window (since this section contains
the fields to add conditional formatting to).
8. Go to the OnFormat property and click the ellipses next to it.
9. The VBScript Editor appears. Enter the following VBScript expression in the editor:
row = row + 1
if row mod 2 = 1 Then
rowColor = Rgb(238, 214, 200)
Else
rowColor = "Transparent"
EndIf
doHighlight = False
if pCondition = 1 Then
doHighlight = UnitPrice > 50
ElseIf pCondition = 2 Then
doHighlight = UnitPrice > 100
ElseIf pCondition = 3 Then
doHighlight = UnitsInStock > 50
EndIf
if doHighlight Then
textColor = pHighlightColor
Else
textColor = Rgb(90, 70, 50)
EndIf
Detail.BackColor = rowColor
for i = 0 to Detail.Fields.Count - 1
Detail.Fields(i).BackColor = rowColor
Detail.Fields(i).ForeColor = textColor
Next
10. Preview the report.
Note: For the complete report, see report 'Conditional Formatting' in the FlexCommonTasks.flxr report
definition file, which is available in the ComponentOne
Samples\Winforms\C1FlexReport\CS\FlexCommonTasks folder. The data base used is C1NWind.mdb which
is also available in the ComponentOne Samples folder.
To specify a custom paper size of 8.5" x 25" for your report using FlexReportDesigner:
CustomHeight=36000
CustomWidth=12472
PaperSize=Custom
When specified this way, the custom paper size is used regardless of what printers are installed and what paper sizes
are actually available.
Note: For the complete report, see report 'Custom Paper Size' in the FlexCommonTasks.flxr report definition
file, which is available in the ComponentOne Samples\Winforms\C1FlexReport\CS\FlexCommonTasks
folder. The data base used is C1NWind.mdb which is also available in the ComponentOne Samples folder.
8. To suppress the page header on first page of a report, set the Layout.PageHeader property of the report
to NotWithReportHdr.
9. Preview the report.
Note: For the complete report, see report 'Dynamic Page Header' in the FlexCommonTasks.flxr report
definition file, which is available in the ComponentOne
Samples\Winforms\C1FlexReport\CS\FlexCommonTasks folder. The data base used is C1NWind.mdb which
is also available in the ComponentOne Samples folder.
5. Go to the report's OnPage property and then click the ellipsis button. The VBScript Editor appears. Enter the
following VBScript expression in the editor:
if page mod 2 = 1 then
Report.layout.marginleft = gutter
Report.Layout.marginright = marginRight
else
Report.layout.marginleft = gutter - 1440
Report.Layout.marginright = marginRight + 1440
EndIf
6. Preview the report.
Note: For the complete report, see report 'Gutter' in the FlexCommonTasks.flxr report definition file, which is
available in the ComponentOne Samples\Winforms\C1FlexReport\CS\FlexCommonTasks folder. The data
base used is C1NWind.mdb which is also available in the ComponentOne Samples folder.
Grouping
Grouping allows you to create groups of records based on common attributes of the records. For example, in this report, all the records
having same EmployeeID are grouped together to form EmployeeGroup. For more information on grouping feature in FlexReport,
refer Grouping Data.
Sorting
Sorting allows you to organize data in ascending or descending order. In FlexReport, the groups are sorted using group expressions.
However, you can change the manner in which the groups are sorted using Group.SortExpression property. The expression may contain
aggregate functions, for example in this report the groups are sorted using Sum(OrderSum) expression which contains an aggregate
function. For more information on sorting, refer Sorting Data.
In this report, the EmployeeGroup is sorted on the basis of total sales in descending order. However, you can also sort the group
alphabetically. In addition, you can provide the sorting options in Parameters Panel too. Please refer the steps below to see how this can
be done.
1. Switch to the Data tab, right-click the Main data source and choose Edit to open and the Data Sources Wizard and start editing.
2. Select OLEDB Data Provider from the Data provider drop-down and click the ellipsis button next to the Connection string
textbox to select the C1NWind.mdb file.
3. Specify the following Sql statement in the Sql statement tab:
1. Switch to the Calculated Fields tab and add two calculated fields with the following properties:
Name FullName OrderSum
2. In the Data tab, right-click Parameters and select Add Parameters to add three parameters, pEmployeeSortExpression,
pEmployeeSortOrder, and pRepeatEmployeeHeader.
3. Set the following properties for the parameters from the Properties window.
pEmployeeSortExpression pEmployeeSortOrder pRepeatEmployeeHeader
Prompt Employees Sort Expression Employees Sort Order Repeat Employee Header
4. Click the ellipsis button next to the AllowedValuesDefinition property, select Values radio button, click Add button to add the
following values for pEmployeeSortExpression and pEmployeeSortOrder parameters:
pEmployeeSortExpression
pEmployeeSortOrder
Note that Add button will add blank values. To edit them, double click below the Label to add the required labels and Values to
add the required values.
OutlineLabel =FullName -
TextField3.Text =Sum(OrderSum)
The Sum(OrderSum) calculates the group total, i.e., total sales for all the orders by an Employee.
6. Add a ParagraphField in the EmployeeGroup_Footer and display the group total using the following expression:
Total Sales for {FullName}:{Sum(OrderSum)}
7. Right-Click the OrderGroup_Header and select Add SubSection from the context menu to divide the header into two parts.
8. In OrderGroup_Header/ <A>, add six more TextFields and set the following properties:
TextField4.Text Order ID
TextField5.Text =OrderID
TextField7.Text =OrderDate
TextField9.Text =ShippedDate
9. In OrderGroup_Header/ <B>, add three more TextFields, Product Name, Unit Price, and Quantity.
10. In the Details section, add three more TextFields corresponding to the TextFields in OrderGroup_Header/ <B>, and set the
TextField14.Text =UnitPrice
TextField15.Text =Quantity
11. In the OrderGroup_Footer, display the subtotal of the order group by using a TextField with its Text property set to
=Sum(OrderSum).
12. Select the report name from the drop-down situated above the list of properties in the Properties window.
13. Go to GlobalScripts property of the report and write following expression in the VBScriptEditor.
EmployeeGroup.SortExpression = pEmployeeSortExpression.Value
EmployeeGroup.Sort = pEmployeeSortOrder.Value
14. Go to OnOpen property of the report and write the following expression in the VBScript Editor.
If pEmployeeSortOrder = "NoSort" Then
fldSortDesc = "No Sorting"
Else
fldSortDesc = pEmployeeSortExpression.DisplayText & " (" & pEmployeeSortOrder.DisplayText & ")"
EndIf
EmployeeGroup_Header.Repeat = pRepeatEmployeeHeader.Value
Note: For the complete report, see report 'Groups and Sorting' in the FlexCommonTasks.flxr report definition file, which is available
in the ComponentOne Samples\Winforms\C1FlexReport\CS\FlexCommonTasks folder. The data base used is C1NWind.mdb
which is also available in the ComponentOne Samples folder.
Cascading Parameters
In order to manage large amount of data in reports, you need to use cascading parameters. With cascading
parameters, set of related parameters can be defined so that the list of values for one parameter depends on the value
selected in another parameter.
Here, we will create a report that contains two parameters pCountry and pCustomers. After selecting a country, you
can select one or more customers from the selected country and list all orders for those customers. The
ReportParameter.DisplayText property is used to display parameters in this report.
Let us create a report in which cascading parameters is used.
1. Create a new report and bind it to the Main data source using the following Sql Statement:
Select orderid, orders.customerid, companyname, employees.firstname,
employees.lastname, orderdate, RequiredDate, shippeddate, Freight
from (orders inner join customers on orders.customerid = customers.customerid)
inner join employees on orders.employeeid = employees.employeeid
where orders.CustomerID in pCustomers
2. Switch to the Calculated Fields tab and add a field named Salesperson with the following expression:
FirstName & " " & lastname
3. Add a new data source, dsCountries, and bind the report to the data source using the following Sql
Statement:
Select Country, Count(*) as CustomerCount
from Customers group by Country order by Country
4. Switch to the Calculated Fields tab and add a field named CountryDesc with the following expression:
Country & " (" & CustomerCount & " customers)"
5. Add another data source named dsCustomers and bind the report to the data source using the following Sql
Statement:
Select CustomerID, CompanyName from Customers where Country = pCountry
6. Add a parameter, pCountry, and set the following properties from the Properties window.
DataType String
Prompt Country
Value Germany
7. Click the ellipsis button next to the AllowedValuesDefinition property, select From Data Source radio button,
and set the following properties:
Data Source dsCountries
Label CountryDesc
Value Country
8. Add a parameter, pCustomers, and set the following properties from the Properties window.
DataType String
MultiValue True
Prompt Customers
9. Click the ellipsis button next to the AllowedValuesDefinition property and select From Data Source radio
button, and set the following properties:
Label CompanyName
Value CustomerID
Note: For the complete report, see report 'Cascading Parameters' in the FlexCommonTasks.flxr report
definition file, which is available in the ComponentOne
Samples\Winforms\C1FlexReport\CS\FlexCommonTasks folder. The data base used is C1NWind.mdb which
is also available in the ComponentOne Samples folder.