Contents
1
Table of Contents 7
Part I Contents 1 Introduction ...................................................................................................................................
7
2 Licensing...................................................................................................................................
7
3 Expressions ...................................................................................................................................
12
Introduction
.......................................................................................................................................................... 13
Text in expressions.......................................................................................................................................................... 13 Calculations of values .......................................................................................................................................................... in expression 14 Multiline expressions .......................................................................................................................................................... 15 Using variables from .......................................................................................................................................................... the dictionary 16 Using variables from .......................................................................................................................................................... the report code 16 Using fields from data .......................................................................................................................................................... sources 17 System variables .......................................................................................................................................................... 19 Using properties of.......................................................................................................................................................... components 20 Functions in expression .......................................................................................................................................................... 20 Expressions with condition .......................................................................................................................................................... 21
4 Text information ................................................................................................................................... output Introduction
21
.......................................................................................................................................................... 21
Output of text parameters .......................................................................................................................................................... 22 Introduction
......................................................................................................................................................... 22
Multiline text
......................................................................................................................................................... 22
Text Trimming ......................................................................................................................................................... 23 Prevention of incompletely ......................................................................................................................................................... visible lines 24 Lines of underlining ......................................................................................................................................................... 24 Maximal number ......................................................................................................................................................... of lines 25 Text rotation
......................................................................................................................................................... 25
Merging of duplicated ......................................................................................................................................................... values 26 Highlight condition ......................................................................................................................................................... 28 Hiding of zero values ......................................................................................................................................................... 29 ReportTo
......................................................................................................................................................... 29
Expressions in text.......................................................................................................................................................... 31 Introduction
......................................................................................................................................................... 31
Text output without ......................................................................................................................................................... expressions 32 Expressions processing ......................................................................................................................................................... in the end of the report rendering 33 Text format Introduction
.......................................................................................................................................................... 33 ......................................................................................................................................................... 34
Standard format......................................................................................................................................................... 37 Numerical format ......................................................................................................................................................... 38 Currency format......................................................................................................................................................... 39 Date format
......................................................................................................................................................... 41
Time format
......................................................................................................................................................... 41
Percentage data ......................................................................................................................................................... format 42 Boolean values......................................................................................................................................................... format 44 Custom format ......................................................................................................................................................... 44 Format in the text ......................................................................................................................................................... 45 Rtf text output Introduction
.......................................................................................................................................................... 46 ......................................................................................................................................................... 46
Š 2003-2008 Stimulsoft
1
2
User Manual Rtf text editor ......................................................................................................................................................... 47 Expressions in ......................................................................................................................................................... the Rtf text 48 Loading the Rtf......................................................................................................................................................... text from the data field 49 System information.......................................................................................................................................................... 50
5 Graphic ................................................................................................................................... information output
53
Introduction
.......................................................................................................................................................... 54
Imaging
.......................................................................................................................................................... 54
Image loading
.......................................................................................................................................................... 56
Image stretching .......................................................................................................................................................... 58 Bar-codes
.......................................................................................................................................................... 59
Shapes
.......................................................................................................................................................... 61
How to transfer an .......................................................................................................................................................... image to the StiImage component 61
6 Styles of................................................................................................................................... components
65
Introduction
.......................................................................................................................................................... 65
Font
.......................................................................................................................................................... 65
Background
.......................................................................................................................................................... 67
Border
.......................................................................................................................................................... 67
Horizontal alignment .......................................................................................................................................................... 68 Vertical alignment .......................................................................................................................................................... 70
7 Report ................................................................................................................................... Introduction
71
.......................................................................................................................................................... 71
Report rendering .......................................................................................................................................................... 71 Report code
.......................................................................................................................................................... 72
Programming language .......................................................................................................................................................... of a report 75 Integration of the report .......................................................................................................................................................... code to VisualStudio.Net 76
8 Bands
...................................................................................................................................
78
Introduction
.......................................................................................................................................................... 78
Types of bands
.......................................................................................................................................................... 79
Bands output
.......................................................................................................................................................... 82
Data bands
.......................................................................................................................................................... 83
Introduction
......................................................................................................................................................... 84
Data source for......................................................................................................................................................... the Data band 84 Virtual Data band ......................................................................................................................................................... 87 List output
......................................................................................................................................................... 88
List with header......................................................................................................................................................... 90 List with footer ......................................................................................................................................................... 92 Lists one after another ......................................................................................................................................................... output 93 Even or odd strings ......................................................................................................................................................... filling 95 Data sorting
......................................................................................................................................................... 97
Data filtration ......................................................................................................................................................... 99 Page bands
.......................................................................................................................................................... 100
Introduction ......................................................................................................................................................... 100 Page header ......................................................................................................................................................... 100 Page footer
......................................................................................................................................................... 102
Reports with grouping .......................................................................................................................................................... 105 Introduction ......................................................................................................................................................... 106 Condition of grouping ......................................................................................................................................................... 107 Group header ......................................................................................................................................................... 108 Group footer ......................................................................................................................................................... 109 Whole group output ......................................................................................................................................................... 110 New page formation ......................................................................................................................................................... 110 Group footers ......................................................................................................................................................... output only 111 Nested groups......................................................................................................................................................... 111 Š 2003-2008 Stimulsoft
Contents
3
Totals of a group ......................................................................................................................................................... 112 Strings numbering ......................................................................................................................................................... in a group 113 Grouping in the ......................................................................................................................................................... multicolumn reports 113 Reports with columns .......................................................................................................................................................... 113 Introduction ......................................................................................................................................................... 114 Columns on a ......................................................................................................................................................... page 114 Columns on the ......................................................................................................................................................... data band 117 Across Then Down ......................................................................................................................................................... column output mode 118 Down Then Across ......................................................................................................................................................... column output mode 120 Minimal number ......................................................................................................................................................... of strings in a column 123 Column headers ......................................................................................................................................................... 124 Column footer......................................................................................................................................................... 126 Headers and footers ......................................................................................................................................................... combination 127 Two bands output.......................................................................................................................................................... on one band 130 Data strings numbering .......................................................................................................................................................... 131
9 Containers ................................................................................................................................... Introduction
132
.......................................................................................................................................................... 132
Bands positioning.......................................................................................................................................................... in a container 133 Containers position .......................................................................................................................................................... 134 Using the StartNewPage .......................................................................................................................................................... property 135 Side by Side reports .......................................................................................................................................................... 135 Multiple tables on.......................................................................................................................................................... one page output 136 Cloning
.......................................................................................................................................................... 137
10 Autosizing ................................................................................................................................... Introduction
138
.......................................................................................................................................................... 139
Automatic change.......................................................................................................................................................... of a size 139 Automatic change.......................................................................................................................................................... of a text size 140 Automatic change.......................................................................................................................................................... of containers size 141 Automatic change.......................................................................................................................................................... of bands size 142 Both bands and columns .......................................................................................................................................................... size changing 143 Binding to the bottom .......................................................................................................................................................... of the component 145 Components shift.......................................................................................................................................................... 147
11 Calculation ................................................................................................................................... of totals Introduction
149
.......................................................................................................................................................... 150
Calculation of totals .......................................................................................................................................................... procedure 150 Totals output in any .......................................................................................................................................................... part of a report 151 The type of a result .......................................................................................................................................................... of an aggregate function 151 Expressions with .......................................................................................................................................................... aggregate functions 152 Totals with conditions .......................................................................................................................................................... 154 Calculation of totals .......................................................................................................................................................... of a page and of a container 155 Calculation of totals .......................................................................................................................................................... of a column 155 Calculation of totals .......................................................................................................................................................... in a code of report events 157 Calculation of growing .......................................................................................................................................................... total 159 Invisible bands
.......................................................................................................................................................... 159
Totals and automatic .......................................................................................................................................................... change of a size 159 Aggregate functions .......................................................................................................................................................... syntax 159 Calculation of totals .......................................................................................................................................................... in hierarchical reports 160
12 Navigation ...................................................................................................................................
163
Introduction
.......................................................................................................................................................... 164
Bookmarks
.......................................................................................................................................................... 164
Tree of bookmarks .......................................................................................................................................................... 166 Hyperlinks
.......................................................................................................................................................... 169
Reports with content .......................................................................................................................................................... 170 Š 2003-2008 Stimulsoft
3
4
User Manual Bookmarks creation .......................................................................................................................................................... using a code 173
13 Developer ................................................................................................................................... FAQ General
175
.......................................................................................................................................................... 175
How to save load ......................................................................................................................................................... a report 175 How to render......................................................................................................................................................... a report 176 How to bind data ......................................................................................................................................................... to a report 177 When should I......................................................................................................................................................... attach data - before loading of a report or after it 177 How to run a report ......................................................................................................................................................... designer 178 How to save load ......................................................................................................................................................... a rendered report 179 How to load DataSet ......................................................................................................................................................... XSD schema 179 How to change......................................................................................................................................................... the current script language of a report 180 Report Designer .......................................................................................................................................................... 180 Our users find the Designer too complicated. What can we do to cut off unwanted functions ......................................................................................................................................................... 181 What can I do ......................................................................................................................................................... to hide tips when running the Designer 181 How to hide the ......................................................................................................................................................... tab page with the report code 181 How to make the ......................................................................................................................................................... Designer not to ask about saving a report before quitting 182 What can I do ......................................................................................................................................................... something after running the Designer but before initialization 182 How to intercept ......................................................................................................................................................... saving/loading a report in the report Designer 182 How to hide something ......................................................................................................................................................... in the data dictionary 182 How to change......................................................................................................................................................... the name of the edited file in the report Designer 183 How to hide a menu ......................................................................................................................................................... element in the designer 183 Work with a report.......................................................................................................................................................... 183 Access to data......................................................................................................................................................... 184 How to change data of ......................................................................................................................................... connection with database 184 How to address to the ......................................................................................................................................... column with data directly without typical conversion 185 How to change a text......................................................................................................................................... of query when report rendering 185 All data are received......................................................................................................................................... by a report. Is it possible to register in a report 186 How to add a parameter ......................................................................................................................................... to SQL query 186 How to render a report ......................................................................................................................................... on the server and send to your client 187 Is it possible to design the report in the designer using a local database and change the database ......................................................................................................................................... in code once online 187 Is it possible to display images, both stored in a database or hosted on a server ......................................................................................................................................... 188 Can I change the report ......................................................................................................................................... connection string on run time 188 How to send parameters ......................................................................................................................................... for SQL query by application 189 How to check null values ......................................................................................................................................... 190 How to render Master-Detail reports if two tables are located on another DataSet ......................................................................................................................................... 190 Formatting and......................................................................................................................................................... converting 190 How to convert coordinates ......................................................................................................................................... of one unit into another 191 How to convert coordinates ......................................................................................................................................... and sizes of a report 191 How to output the value ......................................................................................................................................... instead of DBNull and Null values 192 Variables
......................................................................................................................................................... 192
How to add a variable ......................................................................................................................................... in a report 192 How to get access to......................................................................................................................................... the value of a variable 193 How to add system variable ......................................................................................................................................... to the text 193 Miscellaneous......................................................................................................................................................... 194 How to change sorting ......................................................................................................................................... of data 195 How to get actual size ......................................................................................................................................... of a component 195 How to find a component ......................................................................................................................................... by its name 195 How to get or set a text ......................................................................................................................................... to rtf component in rtf format 196 How should I add a bookmark ......................................................................................................................................... for a component using code 196 What is the difference ......................................................................................................................................... between the Text and the TextValue 196 What should I specify ......................................................................................................................................... in the DataColumn field of an image 196 Š 2003-2008 Stimulsoft
Contents
5
How to load image from ......................................................................................................................................... the path, stored in database 197 How to bind ComboBox ......................................................................................................................................... on Form to Data 197 How to get access to......................................................................................................................................... the text of the report code 198 How to generate a new ......................................................................................................................................... code of a report 198 How to update a report ......................................................................................................................................... code 198 How to use custom assemblies ......................................................................................................................................... in a report 199 How should I get access ......................................................................................................................................... to objects of my application from a report 199 How to work with columns ......................................................................................................................................... which names concur with the csharp key word 201 How to load an image ......................................................................................................................................... from URL 201 How to find the name......................................................................................................................................... of the file from which the report was loaded 202 How to change CheckBox ......................................................................................................................................... value on a page in preview 202 How to change the page ......................................................................................................................................... number 203 Are there any ways to ......................................................................................................................................... print a header for a databand on the second page 203 How to minimize the font size of the text component depending on the text size ......................................................................................................................................... 204 How to change duplicated ......................................................................................................................................... values on a band with one 204 How to add the event......................................................................................................................................... handler to events 205 How to get access to......................................................................................................................................... pages of a report 206 How to get the total of ......................................................................................................................................... a band without its printing 206 How to sort data on the ......................................................................................................................................... base of the Expression 206 Cross-report rendering ......................................................................................................................................... by 3 tables 208 Text formatting in the......................................................................................................................................... RichText component in the GetValue event handler 208 Work with compiled .......................................................................................................................................................... report 211 How to compile ......................................................................................................................................................... report to assembly 211 How to load a report ......................................................................................................................................................... from assembly into the memory once only 211 How to use the......................................................................................................................................................... compiled report assembly 212 How to get compatibility of versions of the report generator and compiled reports ......................................................................................................................................................... 213 How to load a report ......................................................................................................................................................... from assembly 214 Preview
.......................................................................................................................................................... 215
How to process ......................................................................................................................................................... saving and loading of a rendered report by myself 215 How to process ......................................................................................................................................................... printing in the Window of Preview 216 How to disable......................................................................................................................................................... buttons in the toolbar 217 How to disable......................................................................................................................................................... the toolbar 218 How to specify to the report generator to output the result of report rendering in the StiPreviewControl ......................................................................................................................................................... 218 How to specify......................................................................................................................................................... to the report generator to use my window of report preview 219 How to set zoom ......................................................................................................................................................... of pages in the StiPreviewControl 220 How to set predefined ......................................................................................................................................................... zoom of pages in the StiPreviewControl 220 How to refresh......................................................................................................................................................... the report preview in the report code 221 How to load a ......................................................................................................................................................... page into the rendered report from the code of the report 221 How to get access ......................................................................................................................................................... to pages of rendered report 222 How to show all ......................................................................................................................................................... components in preview but do not print them 223 How to add or ......................................................................................................................................................... change an image in the rendered report in the report code 223 How to indicate pressing the cancel button in the Window of Preview and do not show the report ......................................................................................................................................................... 225 How to attach ......................................................................................................................................................... your indicator of pages rendering 226 Why the text I ......................................................................................................................................................... have printed does not look similar with the text in Preview 227 Printing Reports .......................................................................................................................................................... 227 How to print a report ......................................................................................................................................................... immediately without preview 227 How to print report ......................................................................................................................................................... without dialog box 228 How to print a ......................................................................................................................................................... report with specified parameters 228 How to print a ......................................................................................................................................................... report with the specified printer 229 How to indicate ......................................................................................................................................................... the specified paper source for printing 230 The end of the......................................................................................................................................................... page is not printed completely. What should I do 231 Š 2003-2008 Stimulsoft
5
6
User Manual How to print copyright ......................................................................................................................................................... on every page of a report 231 Why the content ......................................................................................................................................................... of the Text is printed without last pixels 233 Export of reports .......................................................................................................................................................... 233 How to export ......................................................................................................................................................... rendered report 234 How to export ......................................................................................................................................................... a report without using the dialog box 234 How to disable......................................................................................................................................................... all unnecessary types of export from the Window of Preview 235 How to export ......................................................................................................................................................... a page with the specified size into the Bitmap 236 When I export a report to Html but not all components which are crossed have been exported......................................................................................................................................................... 236 How, using the......................................................................................................................................................... RichText, to output the text in the RTF format 236 The ExcelValue ......................................................................................................................................................... property 237 Configuration
.......................................................................................................................................................... 237
What can I do ......................................................................................................................................................... to load or save report configuration 238 What can I do ......................................................................................................................................................... if I do not want to save configuration 238 How to restore......................................................................................................................................................... configuration by default 238 How to use more ......................................................................................................................................................... then one configurations concurrently 238 How to save configuration ......................................................................................................................................................... in database 238 How to attach ......................................................................................................................................................... your own TraceListener 238 How to show all ......................................................................................................................................................... exceptions which are invoked in StimulReport.Net 239 How, in StimulReport.Net, ......................................................................................................................................................... to disable all dialog boxes with messages 239 How to change......................................................................................................................................................... the current localization of the report generator 239 How to change......................................................................................................................................................... the path to resources of localization 240 How, in addition ......................................................................................................................................................... to English, to add other languages to localization 240 How to decrease ......................................................................................................................................................... the number of levels of relations in business objects 240 How to enable......................................................................................................................................................... RightToLeft in the Window of Preview 240 Which units are ......................................................................................................................................................... used to store report coordinates 240 How to change......................................................................................................................................................... the current unit in the report 241
Š 2003-2008 Stimulsoft
Contents
1
7
Contents
Contents Introduction
7
Changes Expressions
12
Text information output
21
Graphic information output Components styling Report Bands
53
65
71
78
Containers 132 Autosizing 138 Calculation of totals 149 Navigation 163 FAQ 175
1.1
Introduction
INTRODUCTION StimulReport.Net is a .NET based report generator which helps you create flexible and feature rich reports. Stimulsoft Reports.Net is delivered with source codes. All reports are created in report designer with handy and user-friendly interface. You can use the report designer both in design time and in runtime. No royalties for using the report designer in runtime are required. Using Stimulsoft Reports.Net you can create reports on the bases of the variety of data sources. Created reports can be used both in Windows Forms and in Asp.Net. Rendered report can be exported to: Pdf, Xml, Html, Excel, Rtf, Txt, Csv, Emf, Bmp, Jpeg, Gif, Png, and Tiff. Stimulsoft Reports.Net is runtime royalty-free.
1.2
Licensing STIMULSOFT, STIMULREPORT.NET DEVELOPER LICENSE AGREEMENT FOR STIMULSOFT SOFTWARE This Stimulsoft, ("STIMULSOFT") Developer License Agreement ("DLA") is a legal agreement between you, software developer ("DEVELOPER") and STIMULSOFT for
Š 2003-2008 Stimulsoft
8
User Manual
STIMULREPORT.NET identified above and including components, source code (if provided), demos, intermediate files, media, printed materials, and "online" or electronic documentation ("SOFTWARE") contained in this installation file. STIMULSOFT grants to you, a personal, nonexclusive license to install and use the SOFTWARE for the sole purposes of designing, developing, testing, and deploying application programs which you create. If you are an entity, you must designate one individual within your use the SOFTWARE in the manner provided herein. The SOFTWARE is runtime royalty-free for Redistributables. By installing, copying, or otherwise using the SOFTWARE, you agree to be bound by the terms of this DLA. If you do not agree to any part of the terms of this DLA, DO NOT INSTALL, USE, DISTRIBUTE IN ANY MANNER, OR REPLICATE IN ANY MANNER, ANY PART, FILE OR PORTION OF THE SOFTWARE. All SOFTWARE is licensed, not sold. The demonstration version includes the following restriction - on all pages the inscription "Demo" is deduced. The full version of a product does not contain these restrictions. It is necessary for you to be registered before use the full version of a product. You can use the demonstration version of a product with an unlimited period of time. RIGHTS You may install and use one copy of the SOFTWARE, including any and all source code if provided, or any prior version legally licensed for the same operating system, on a single computer. Developer may make two additional copies of the SOFTWARE: a second copy for his or her exclusive use on a portable computer and a third copy for his or her exclusive use on a home computer. You acknowledge and agree that the SOFTWARE in source code if provided form remains a confidential trade secret of STIMULSOFT. You may transfer all of your rights to use the SOFTWARE to another person, provided that you transfer to that person all of the software, diskettes (if applicable), and documentation provided in this package (including this license agreement), and transfer or destroy all copies in any form. Remember, once you transfer the SOFTWARE, you no longer have any right to use it, and the person to whom it is transferred may use it only in accordance with the copyright law, international treaty, and this license. REGISTER THIS SOFTWARE, DEVELOPER LICENSE GIVES YOU THE RIGHT TO: All the potential of a registered version become available for you; Free technical support with high priority and notifications on the new versions of SOFTWARE;
Š 2003-2008 Stimulsoft
Contents
9
Updates, upgrades (to all minor and major versions) and fixes. STIMULSOFT will provide you with free updates, upgrades (to all minor and major versions) and fixes of the SOFTWARE, within one year after you purchase it. If you are using the demonstration version of the SOFTWARE, STIMULSOFT will not provide you updates, upgrades to minor version and fixes related to the SOFTWARE. To register SOFTWARE read file "readme.rtf" or visit web-site http://www.stimulsoft.com. RESTRICTIONS You may not rent, lease, lend, copy, modify, sub-license, time-share, electronically transmit or receive the Software, except as provided in this license, or as directed by STIMULSOFT. You may not translate, reverse engineer, decompile or disassemble or otherwise alter the Software or its documentation. You may not reverse engineer, decompile, create derivative works, modify, translate, or disassemble the SOFTWARE, and only to the extent that such activity is expressly permitted by applicable law notwithstanding this limitation. You agree to take all reasonable, legal and appropriate measures to prohibit the illegal dissemination of the SOFTWARE or any of its constituent parts and redistributables to the fullest extent of all applicable local, US Codes and International Laws and Treaties regarding anti-circumvention, including but not limited to, the Geneva and Berne World Intellectual Property Organization (WIPO) Diplomatic Conferences. The DEVELOPER shall not expose SOFTWARE API to its customers, but only its own API. The DEVELOPER may NOT distribute the SOFTWARE, in any format, to other users for development or application compilation purposes. Specifically, if DEVELOPER creates a component using the SOFTWARE as a constituent component, DEVELOPER may NOT distribute the component created with the SOFTWARE (in any format) to users to be used at design time and or for ANY development purposes. This restriction applies to “design time” within IDE (Microsoft Visual Studio and others). YOU MAY NOT CREATE ANY TOOL OR SOFTWARE THAT DIRECTLY OR INDIRECTLY COMPETES WITH THE SOFTWARE WHICH UTILIZES ALL OR ANY PORTION OF THE SOFTWARE. The SOFTWARE is licensed as a single PRODUCT. The SOFTWARE and its constituent parts and any provided redistributables may not be reverse engineered, decompiled, disassembled or separated for use on more than one computer, nor placed for distribution, sale, or resale as individual creations by DEVELOPER. The provision of source code, if included with the SOFTWARE, does not constitute transfer of any legal rights to such code, and resale or distribution of all or any portion of all source code and intellectual property will be prosecuted to the fullest extent of all applicable local, federal and international laws. All STIMULSOFT libraries, source code if provided, redistributables and other files remain STIMULSOFT exclusive property. You may not distribute any files, except those that STIMULSOFT has expressly designated as Redistributable.
© 2003-2008 Stimulsoft
10
User Manual
SOFTWARE may include certain files ("Redistributables") intended for distribution by you to the users of programs you create. Redistributables include those files selected for deployment by an install utility provided with the SOFTWARE. In any event, the Redistributables for the SOFTWARE are only those files specifically designated as such by STIMULSOFT. Subject to all of the terms and conditions in this DLA, you may reproduce and distribute exact copies of the Redistributables, provided that such copies are made from the original copy of the SOFTWARE or the copy transferred to a single hard disk. Copies of Redistributables may only be distributed with and for the sole purpose of executing application programs permitted under this DLA that you have created using the SOFTWARE. Under no circumstances may any copies of Redistributables be distributed separately.
REDISTRIBUTABLES The following files are considered redistributables under this DLA: Stimulsoft.Controls.dll Stimulsoft.Base.dll Stimulsoft.Editor.dll Stimulsoft.Report.dll Stimulsoft.Report.Web.dll Localization files YOU ARE NOT AUTHORIZED TO REDISTRIBUTE ANY OTHER FILE CONTAINED IN THE SOFTWARE. COPYRIGHT All title and copyrights in and to the SOFTWARE (including but not limited to any images, demos, source code if provided, intermediate files, packages, photographs, distributables, animations, video, audio, music, text, and "applets" incorporated into the SOFTWARE the accompanying printed materials, and any copies of the SOFTWARE) are owned by STIMULSOFT or its subsidiaries. The SOFTWARE is protected by copyright laws and international treaty provisions. Therefore, you must treat the SOFTWARE like any other copyrighted material except that you may install the SOFTWARE on a single computer provided you keep the original solely for backup or archival purposes. You may not copy the printed materials accompanying the SOFTWARE. INSTALLATION AND USE The license granted in this DLA for you to create your own compiled programs and distributes your programs and the Redistributables (if any), is subject to all of the following conditions: 1. You may not remove or alter any STIMULSOFT copyright, trademark or other proprietary rights notice contained in any portion of STIMULSOFT libraries, source code if provided, Redistributables or other files that bear such a notice; 2. STIMULSOFT provides no warranty at all to any person, other than the Limited Warranty provided to the original purchaser of the SOFTWARE, and you will remain solely responsible to anyone receiving your programs for support, service, upgrades, or technical or other assistance, and such recipients will have no right to contact STIMULSOFT for such services Š 2003-2008 Stimulsoft
Contents
11
or assistance; 3. You will indemnify and hold STIMULSOFT its related companies and its suppliers, harmless from and against any claims or liabilities arising out of the use, reproduction or distribution of your programs; 4. Your programs containing SOFTWARE must be written using a licensed, registered copy of the SOFTWARE; 5. Your programs must add primary and substantial functionality, and may not be merely a set or subset of any of the libraries, code, Redistributables or other files of the SOFTWARE; 6. You may not use STIMULSOFT’s or any of its supplier’s names, logos, or trademarks to market your programs. TERMINATION Without prejudice to any other rights or remedies, STIMULSOFT will terminate this DLA upon your failure to comply with all the terms and conditions of this DLA. In such events, you must destroy all copies of the SOFTWARE and all of its component parts including any related documentation, and must remove ANY and ALL use of such technology immediately from any applications using technology contained in the SOFTWARE developed by you, whether in native, altered or compiled state. LIMITED WARRANTY NO WARRANTIES. STIMULSOFT expressly disclaims any warranty for the SOFTWARE. THE SOFTWARE AND ANY RELATED DOCUMENTATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT. THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE REMAINS WITH YOU. To the maximum extent permitted by applicable law, in no event shall STIMULSOFT be liable for any special, incidental, indirect, or consequential damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use the SOFTWARE or the provision of or failure to provide Support Services, even if STIMULSOFT has been advised of the possibility of such damages. SUPPORT SERVICES STIMULSOFT may provide you with support services related to the SOFTWARE ("Support Services"). Use of Support Services is governed by the STIMULSOFT policies and programs described in the user manual, in "on line" documentation and/or other STIMULSOFTprovided materials. Any supplemental SOFTWARE code provided to you as part of the Support Services shall be considered part of the SOFTWARE and subject to the terms and conditions of this DLA. With respect to technical information you provide to STIMULSOFT as part of the Support Services, STIMULSOFT may use such information for its business purposes, including for SOFTWARE support and development. STIMULSOFT will not utilize such technical information in a form that personally identifies you. GENERAL PROVISIONS © 2003-2008 Stimulsoft
12
User Manual
This DLA may only be modified in writing signed by you and an authorized officer of STIMULSOFT. If any provision of this DLA is found void or unenforceable, the remainder will remain valid and enforceable according to its terms. If any remedy provided is determined to have failed for its essential purpose, all limitations of liability and exclusions of damages set forth in the Limited Warranty shall remain in effect. You, as the DEVELOPER, agree and ascend to the adherence to all applicable international treaties regarding copyright and intellectual property rights which shall also apply. In addition, you, as DEVELOPER, agree that any local law(s) to the benefit and protection of STIMULSOFT ownership of, and interest in, its intellectual property and right of recovery for damages thereto will also apply. IF CONDITION OF THIS LICENSE DISAGREES WITH LOCAL LAW(S), THAN YOU CAN NOT USE SOFTWARE. MISCELLANEOUS STIMULSOFT reserves all rights not specifically granted in this DLA. This license is subject to change without notice in future updates to the SOFTWARE. YOU ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. YOU FURTHER AGREE THAT IT IS THE COMPLETE AND EXCLUSIVE STATEMENT OF THE AGREEMENT BETWEEN US, WHICH SUPERSEDES ANY PROPOSAL OR PRIOR AGREEMENT, ORAL OR WRITTEN, AND ANY OTHER COMMUNICATIONS BETWEEN US RELATING TO THE SUBJECT MATTER OF THIS AGREEMENT. Copyright (C) 2003-2007 Stimulsoft, All rights reserved.
1.3
Expressions
Expressions Introduction
13
Text in expressions
13
Calculations of values in expression Multiline expressions
14
15
Use of variables from the dictionary
16
Use of variables from the report code Use of fields from data sources System variables
16
17
19
Use of properties of components
20
Š 2003-2008 Stimulsoft
Contents
Functions in expression
20
Expressions with condition
1.3.1
13
21
Introduction
Introduction Expression is a combination of mathematical and logical operators, absolute symbols, functions, field names, controls, and, as a result of processing of the expression, the unique string value is returned. This value is stored and used in subsequent work. Expressions, which are frequently used in the report generator, are text expressions. This type of expressions is used for getting a text that will be printed. Text expressions are always converted into a string. Name of the property in which the expression is recorded Text Bookmark Hyperlink Tag Tooltip Checked Filter Condition Code
1.3.2
Property in which the result of calculation of Description the expression is recorded TextValue This property is used for getting a text for printing. Always converts into a string. BookmarkValue This property is used to calculate the bookmark value. HyperlinkValue This property is used to calculate the hyperlink strings. TagValue This property is used to calculate the Tag field value. TooltipValue This property is used to calculate the string output in the Window of Preview. CheckedValue This property is used to calculate the string output in the Window of Preview. This property is used to calculate the filter for the Data band. This property is used to calculate the condition of grouping in the GroupHeader band. CodeValue This property is used to calculate the code string for the bar-code output.
Text in expressions
Text in expressions The simplest expressions are expressions which contain only the text. For example: MyText Š 2003-2008 Stimulsoft
14
User Manual
12345 Test These three expressions consist of one string and do not include calculations. Expressions of such a type are used for indicating simple string constants, absolute symbols, column names, reports, references etc. 1.3.3
Calculations of values in expression
Calculations of values in expression The expression, except the simple text, can also include variables, field values from databases, functions. For this, you may add parts of a code in expression. The code is written in programming language of a report. For selecting a code, use “{“ and “}”. The “{“ symbol is the beginning of a code for value calculation. The “}” symbol is the end of a code for calculation of value. The code inside of these symbols is calculated and substituted for the result of calculation. In text expressions the result of calculation is automatically converted into the string. For example, see the following expression: Value = {1 + 2}
- returns the following text after calculation: Value = 3
In one expression the unlimited quantity of code nestings for the value calculation are allowed. For example: ValueA = {1 + 2}, ValueB = {2 + 3}
- returns the following text after calculation: ValueA = 3, ValueB = 5
In this expression the code nesting for the value calculation is not allowed. For example, the following expression is incorrect:
Value = {1 + 2 + {2 + 3}} © 2003-2008 Stimulsoft
Contents
15
Notice. In this expression the code nesting for the value calculation is not allowed.
1.3.4
Multiline expressions
Multiline expressions Is it possible to set the multiline text into the expression? All you need to do for creation of the multiline expression is to put the line feed before a new line (in the code editor the line feed is set by pressing Enter). For example: Value: {1+2}
-after calculation this expression will print the following lines: Value: 3
In other words the expression will contain two lines. There is no limit in the number of lines in the report generator. Notice. The expression may contain any number of lines. Multiline expressions have no limit in use of the code for calculation of value. The same principles of calculation of multiline expressions are used in calculation of single-line expressions. Beside, while creating multiline expressions, the code cannot to be separated with the line feed. For example: Value: {1 + 2}
- this expression is incorrect. It is a correct entry: Value: {1 + 2}
It is a correct one too:
Š 2003-2008 Stimulsoft
16
User Manual
Value: {1 + 2}
Notice. The code in expressions cannot to be separated with the line feed.
1.3.5
Using variables from the dictionary
Using variables from the dictionary In expressions, you may use variables, created in the dictionary. For this, just specify the name of a variable in the expression. For example: {MyVariable}
- instead of a variable name, its value will be used. Notice. In the expression use names of variables only. Aliases cannot be used. Variables can be used in calculations. For example: Value = {MyVariable + 10}
- if the MyVariable variable is 15 then this expression will return the following string: Value = 25
Important! If the programming language is C#, then the register of names of variables is to be considered. If the programming language is VB.Net, then the register of names of variables should not be considered.
1.3.6
Using variables from the report code
Using variables from the report code The report generator allows you to add any additional code into the report code. This capability can be used for processing of variables. These variables can always be used in expressions in the report.
Š 2003-2008 Stimulsoft
Contents
17
Principles of use of variables from the report code are the same as principles of use of variables from the dictionary. But you should know that only variables from the dictionary can be used for calculation of any values. For example, calculation of the progressive total. Important! Only variables from the dictionary can be used for calculation of any values.
1.3.7
Using fields from data sources
Using fields from data sources In expressions you may use values from data sources. For this purpose, use the reference in the expression on the field from the data source. The reference is the string representation of the field. First, specify the name of the data source and then specify the name of the field. Separate the name of the data source and the name of the field with points: {DataSource.Field}
For example:
Š 2003-2008 Stimulsoft
18
User Manual
{Customers.CompanyName}
-this expression will return the name of the company. If the data source has parent relations with other data sources you may use fields from parent of the data source. So after the field name of the data source input the name of the relation. And then input the field name. The field name of the data source, the name of the relation and the field name are to be separated with points: {Datasource.Relation.Field}
For example: {Products.ParentCategories.CategoryName}
Here: · Products – a data source name; · ParentCategories – a name of relation of two data sources. In this case two data sources: Products – list of product, and Categories – list of categories of these products are bound together. · CategoryName – the of the column in the Categories data source. As a result of the calculation, the expression will return names of categories for product. Notice. Use only data sources names, relations, and fields in the expression. Aliases cannot be used. StimulReport.Net does not impose a limitation on the number of relation transfer. In other words working with column you may apply to it two or more relations. For example: {OrderDetails.ParentProducts.ParentCategories.CategoryName}
in this expession: · OrderDetails – the name of the data source; · ParentProducts - the name of the relation between the OrdersDetails data source and Products; · ParentCategories – the name of the relation between the Products data source and Categories; © 2003-2008 Stimulsoft
Contents
19
· CategoryName – the field in the Categories data source. As you can see, the value of the CategoryName field has been obtained using relation bypassing from the OrderDetails data source to the Categories data source. No direct call to the Categories data source where used. Important! If the programming language is C# then the register of names of variables is to be meant. If the programming language is VB.Net then the register of names of variables should not be considered. 1.3.8
System variables
System variables StimulReport.Net offers to use system variables in expressions. System variables are variables which informs you of the current state of a report. Let examine system variables: · Line – returns the current number of line. Use it for lines numbering in reports. Numbering starts with 1. Numbering for each group is separated; · LineThrough – returns through number of the line. Unlike the Line variable the LineThrough variable returns the number of a line from the very beginning of a report without report grouping. Numbering starts with 1; · PageNumber – returns the current number of a page. The page numbering starts with 1. Used for page numbering; · TotalPageCount – returns the total number of pages in the report; · PageNofM – returns the string according to a conventional commonplace pattern: Page {PageNumber} from {TotalPageCount}
The variable is used for page numbering with the number of pages indication. · Column – returns the current number of a column. Used for numbering columns in the report; · Date – returns the current date; · Time – returns the current time; · ReportName - returns the report name; · ReportAlias - returns the report alias; · ReportAuthor - returns the report author; · ReportChanged - returns the date of the recent report change; · ReportCreated - returns the date of the report creation; © 2003-2008 Stimulsoft
20
User Manual
路 ReportDescription - returns the report description. 1.3.9
Using properties of components
Using properties of components In expressions you can use component properties. Syntax corresponds to C# or VB.Net syntax. {Component.Property}
For example, if you want to call to the component name: {MyComponent.Name}
If, in expression, it is necessary to specify the result of calculation of another expression you should not use the property of the expression but you should use the property in which the result is entered: For example, values of hyperlinks: {MyComponent.HyperlinkValue}
1.3.10 Functions in expression
Functions in expression StimulReport.Net does not have built-in functions. But, due to the fact, that StimulReport.Net is closely integrated with .Net Framework, it is no more the problem. You can use any functions available in .Net Framework. For example, for string values: {MyString.Trim()}
{"Test".ToUpper()}
{MyString.Length}
For values: {Math.Round(MyValue, 2)} 漏 2003-2008 Stimulsoft
Contents
21
{Math.Sqrt(MyValue)}
{MyValue.ToString() + " "}
1.3.11 Expressions with condition
Expressions with condition StimulReport.Net excludes a condition in the expression by default. However, using C# programming language, you can use ternary operation. See the following ternary operations: {Condition ? Value1 : Value2}
If Condition returns true then the expression will return Value1. If no, then Value2. For example: {Store.Count > 0 ? Store.Count : "Empty"}
1.4
Text information output
Text information output Introduction
21
Output of text parameters Expressions in text Text format
31
33
Rtf text output
46
System information 1.4.1
22
50
Introduction
Introduction Text is one of the parts of every report. In StimulReport.Net, for text output, you can use the following components: Text, SystemText, ContourText и RichText (RichText has other © 2003-2008 Stimulsoft
22
User Manual
ways of functioning and is viewed in the special chapter). Text components have rich set of styles and options. For setting, a lot of parameters are available: position and size, frame, fill, alignment, font etc. Beside styles, text components offer a lot of parameters of the text output. 1.4.2
Output of text parameters
Output of text parameters Introduction
22
Multiline text
22
Text trimming
23
Prevention of incompletely visible lines Lines of underlining
24
Maximal number of lines Text rotation
25
25
Merging of duplicated values Highlight condition
1.4.2.1
26
28
Hiding of zero values ReportTo
24
29
29
Introduction
Introduction There are a lot of properties for text components. Changing these properties you can stylize your text. This chapter is devoted to many properties. The most part of them is used for text components only. 1.4.2.2
Multiline text
Multiline text If the text cannot be put on one line it will be trimmed by default. If it is required to put a text on some lines, then you should set the word wrap. You should set the TextOptions. WordWrap property of the Text component in True. When the text is wrapped on a new line, vertical and horizontal alignments are used.
Š 2003-2008 Stimulsoft
Contents
1.4.2.3
23
Text Trimming
Text trimming If the text cannot be put on one line then, using the TextOptions.Trimming property, you can automatically add marks of omission. The Trimming property has following values: None – the text is trimmed strictly by the margin of a rectangle or, if it is a multiline text, by the last visible word;
Character – the line is trimmed after the last visible character;
Word – the line is trimmed after the last visible word;
Ellipsis Character – last characters of a word are changed to dots;
© 2003-2008 Stimulsoft
24
User Manual
Ellipsis Word – dots are added after the last visible word;
Ellipsis Path – the middle of a line is changed to dots so as the beginning and the end of a line can be visible.
1.4.2.4
Prevention of incompletely visible lines
Prevention of incompletely visible lines Often you need to output a text without vertical incompletely visible lines on the bottom. If to set the LineLimit property in True then only completely visible lines will be seen. Absence of additional line may change the word wrap.
1.4.2.5
Lines of underlining
Lines of underlining If to set the LinesOfUnderlining property in True then every line of the Text component will be underlined.
© 2003-2008 Stimulsoft
Contents
1.4.2.6
25
Maximal number of lines
Maximal number of lines How to make the Text component, when increasing the vertical size, increase it on the maximal number of horizontal lines? Use the MaxNumberOfLines property. By default, this property is equal in zero and the component will be increased vertically. The component increasing is limited in page size. If you set the value of this property in 5, then, when increasing the vertical size, it will be increased in 5 horizontal lines. 1.4.2.7
Text rotation
Text rotation Using the TextOptions.Angle property you may set text rotation. Angle of rotation is set in degrees anticlockwise.
For setting standard values of the text rotation (0, 45, 90, 180, and 270 degrees) it is recommended to use the Formatting button on the toolbar.
Š 2003-2008 Stimulsoft
26
User Manual
The button for selecting text rotation property The panel of standard angles for text rotation 1.4.2.8
Merging of duplicated values
Merging of duplicated values In many reports there is a necessity to merge a few Text components in one which contain duplicated values. If you want the Text component to merge equal values you should set the value of the ProcessingDuplicates property in True. See the following pattern of merging of equal text values.
Š 2003-2008 Stimulsoft
Contents
Š 2003-2008 Stimulsoft
27
28
1.4.2.9
User Manual
Highlight condition
Highlight condition Highlight condition allows you to modify the format of the Text component that depends on the condition. You can setup the Highlight Condition using the HighlightCondition property or the button on the Formatting toolbar.
This button calls the highlight condition Parameters of the highlight condition are specified in the special window. In the window of highlight condition parameters of the component format and conditions can be specified.
Condition If the condition is not true then the component format is changed to the one specified in parameters. Š 2003-2008 Stimulsoft
Contents
29
Parameters of the text This group contains parameters of the selected format of a component. Parameters of the background This group contains parameters of the background fill of the selected component. Notice! If you want to remove the conditional formatting just clear the text of condition A condition can be an expression. If a condition is true then the Text component format will be changed. For setting, the TextBrush, Font and Brush properties are available. For example, if stocks of products are zero, then the line can be marked as red. For making this procedure you should write: Products.UnitsInStock == 0
In the Brush property set the red color, and for the TextBrush component - white color.
(See Demo, Highlight Condition).
1.4.2.10 Hiding of zero values
Hiding of zero values Often, when numerical information is to be printed, hiding of zero values required. In other words they must not be printed. Set the value of the HideZeros property in True and the Text component will not print zero values. 1.4.2.11 ReportTo
ReportTo The ReportTo property of the Text component is used for synchronous output of a message in two text components. The message is specified in the first text component. Then, in this text component, in the ReportTo property, the second text component, in which message output will be continued, is specified. If the space in the first component is not enough for the Š 2003-2008 Stimulsoft
30
User Manual
message output, then this message will be continuing to output in the second component. You should consider, that in the first component, whole number of vertical visible lines will be output. In the second component the message will be continuing to output starting with the end of the message of the first component. You should know that for the correct work of this function you have to create the first component and then the second one. If there was another order of creation of components you may use commands of components order. See the example below.
See the result of a rendered report on the picture below.
Š 2003-2008 Stimulsoft
Contents
31
The Report To property allows you to work only with components which are positioned on one level, for example, on a band. 1.4.3
Expressions in text
Expressions in text Introduction
31
Text output without expressions
32
Expressions processing in the end of the report rendering 1.4.3.1
33
Introduction
Introduction All the text that is seen in the report is being formed with text expressions. Text expressions do not differ from other expressions. Expressions are specified in the Text property. This property is available in the following components: Text, SystemText, CounterText. Š 2003-2008 Stimulsoft
32
User Manual
The text expression has one distinction from other expressions. The final result depends on the text format. Beside, you can specify additional options to text expressions, which effect on the final form of a text. 1.4.3.2
Text output without expressions
Text output without expressions What can you do to output expression without code processing? Set the value of the TextOnly property in True, and then all expressions will be output as a text. No calculations will be processed.
Š 2003-2008 Stimulsoft
Contents
33
The TextOnly property is true. The text is output without processing of the expression. The TextOnly property is false. The text is output with processing of the expression. 1.4.3.3
Expressions processing in the end of the report rendering
Expressions processing in the end of the report rendering By default, the report generator processes all expressions which are met in the text immediately. But sometimes there is a necessity to process expressions after the report rendering. For example, while report rendering, the calculation of a variable is in process. The result of calculation will be known right after the report rendering, and the result of calculation is to be output on every page of a report. Notice. The expression of Text components, which properties are in true are processed in the end of the report rendering. How to make the report generator calculate and output an expression after the report rendering? For this, set the value of the ProcessAtEnd property of the Text component in true. Important! When the content of the text component is processed in the end of the report rendering, the report generator cannot define the true size of the component when it is output. Therefore, auto change of the component size will work with failure.
1.4.4
Text format
Text format Š 2003-2008 Stimulsoft
34
User Manual
Introduction
34
Standard format
37
Numerical format Currency format Date format
41
Time format
41
38
39
Percentage data format Boolean values format Custom format
44
44
Format in the text 1.4.4.1
42
45
Introduction
Introduction Text format is output of information in the special form, grouping and data output, in order to the specified pattern. StimulReport.Net contains all tools required for formatting of all information being output. The Text Format is the base tool for formatting a text before output. This tool is a dialog box, which allows you to setup parameters of format. Text format dialog box is called from the contextual menu, that appears when right-clicked in the text components, which supports formatting.
Š 2003-2008 Stimulsoft
Contents
Also, using TextFormat properties, the dialog box can be called.
Š 2003-2008 Stimulsoft
35
36
User Manual
The Window of Format is divided in three parts:
Š 2003-2008 Stimulsoft
Contents
37
Here you can choose the type of format. You may choose the following types of format: General - data output without formatting; Number — numerical data formatting; Currency — currency data formatting; Date — date data formatting; Time — time data formatting; Percentage — percentage data formatting; Boolean — Boolean data formatting; Custom — custom data formatting. Here you can see a sample of the text; Here you can specify option of formatting. 1.4.4.2
Standard format
Standard format Standard format is used for text output and numerical values of arbitrary type. When you choose this option no formatting is in process.
© 2003-2008 Stimulsoft
38
1.4.4.3
User Manual
Numerical format
Numerical format Use the Numerical format for numerical values output (recommended).
Š 2003-2008 Stimulsoft
Contents
39
Group separator When you use the Group separator, numerical values are divided into groups of numbers. Local setting When you use the Local settings, numerical values are formed according to the current OS installations. Decimal digits Number of decimal digits, which are used in numerical values formatting. Decimal separator The string that is being used as a decimal separator in numerical values formatting. Group separator The string that is used as a group separator in numerical values formatting. Group size The number of digits in each group in numerical values formatting. Negative pattern The pattern that is used for negative numerical values formatting. Null display String display of values equal in null. 1.4.4.4
Currency format
Currency format Š 2003-2008 Stimulsoft
40
User Manual
Use the Currency format for currency output. Currency format can be used for both numbers output and for currency output.
Use group separator When you use the Group separator, numerical values are divided into groups of numbers. Use local setting When you use the Local settings, numerical values are formed according to the current OS installations. Decimal digits Number of decimal digits which are used in numerical values formatting. Decimal separator The string that is being used as a decimal separator in numerical values formatting. Group separator The string that is being used as a group separator in numerical values formatting. Group size The number of digits in each group in numerical values formatting. Positive pattern The pattern that is used for positive numerical values formatting. Negative pattern The pattern that is used for negative numerical values formatting. Currency symbol This symbol is used as a currency symbol; Š 2003-2008 Stimulsoft
Contents
41
Null display String display of values equal in null. 1.4.4.5
Date format
Date format The Date format is used for date output. The date format output can be selected from the set of formats as follow: short date format, long date format etc. In all formats, except ones which are marked with the (*) symbol, the order of elements is not changed. Instead of null date values, when formatting, values from the Null Display field are used.
Date format The date format list Null display String display of values equal in null. 1.4.4.6
Time format
Time format Š 2003-2008 Stimulsoft
42
User Manual
The Time format is used for time output. For data of the Time type you can select two types of the time output as follow: short type of time output and long type of time output with seconds.
Time format The time format list
1.4.4.7
Percentage data format
Percentage data format This format is used for values with percentage output. When formatting the value is multiplied by 100. After the value the percent sign is added.
Š 2003-2008 Stimulsoft
Contents
43
Use group separator When you use the Group separator, numerical values are divided into groups of numbers. Use local setting When you use the Local settings, numerical values are formed according to the current OS installations. Decimal digits Number of decimal digits, which are used in numerical values formatting. Decimal separator The string that is used as a decimal separator in numerical values formatting. Group separator The string that is used as a group separator in numerical values formatting. Group size The number of digits in each group in numerical values formatting. Positive pattern The pattern, that is used for positive numerical values formatting. Negative pattern The pattern, that is used for negative numerical values formatting. Percentage symbol This symbol is used as a percentage symbol. Null display String display of values equal in null.
Š 2003-2008 Stimulsoft
44
1.4.4.8
User Manual
Boolean values format
Boolean values format This format is used for formatting of values of the boolean type.
The string value for identification of the boolean values as false. The string value for boolean value display as false. The string value for identification of the boolean values as true. The string value for boolean value display as true. The string value of null values. 1.4.4.9
Custom format
Custom format This type of format used to setup data format output in the Format Mask field.
Š 2003-2008 Stimulsoft
Contents
45
Mask The value formatting string set by a user. Predefined values The list of predefined values for string format. 1.4.4.10 Format in the text
Format in the text The Text Format tool allows you to format values using a lot of parameters and options. But this tool has one weak point. Formatting is applied on the whole text object. For example, if the text component is used for data output then there is no problems with formatting. But what can you do if you want to format only one value from an expression? Or what can you do if you want to format two or more values of expression? In this case we recommend you use the string.Format method. Using this method you can make almost the same kinds of formatting as if you use the Text Format tool. But the string.Format method has much flexibility. For example, if you want to format the value as a currency you should use the С specificator: Currency values: {string.Format(“{0:C}”, Value) }
© 2003-2008 Stimulsoft
46
User Manual
if the Value is 123.12 then after calculation you will get the following line: Currency values: $123.12
Also the string.Format method takes more than one parameter for formatting. For example: Currency values: {string.Format(“value1 - {0:C}, value2 - {0: 1}”, Value1, Value2) }
You can find more information of the string.Format method in MSDN. 1.4.5
Rtf text output
Rtf text output Introduction
46
Rtf text editor
47
Expressions in the Rtf text
48
Loading the Rtf text from the data field 1.4.5.1
49
Introduction
Introduction StimulReport.Net allows you to include the Rtf format in reports without any limitations. The RichText component is a component for working with Rtf text. This component can automatically change its size depending on the Rtf text size in it, can process expressions, supports variety of styles, processing in the end of the report rendering etc.
© 2003-2008 Stimulsoft
Contents
1.4.5.2
47
Rtf text editor
Rtf text editor For the Rtf text editing the RichText component has the special editor. This editor is able to load and save the Rtf text, change a font, font size, text color, insert expressions etc. Using this editor you can do anything with your Rtf text without other editor's assistance. The editor is called when double-clicked in the RichText component.
Š 2003-2008 Stimulsoft
48
User Manual
Loads a text from a file Saves a text in a file Insert expression Undo/Redo Font options Font name and size Font setting Text color Text alignment List 1.4.5.3
Expressions in the Rtf text
Expressions in the Rtf text The Rtf text in the RichText component is an expression. There is no any significant Š 2003-2008 Stimulsoft
Contents
49
distinctions in work with expressions in the RichText component and in work of other text components. The syntax and use of expressions is similar to the syntax and use of expressions in text components. But there is a particular feature. Formatting must not break the code for values calculation in fragments. In other words if you want to write the value in the Rtf text and this value is calculated with use of a code, selected with color, you should set this color for all the code. The code in expression opens with { and closes with }. Correspondingly, any formatting should belong to the code from the opening { to the closing } including these symbols. For example:
- {Categories.CategoryName} this is the part of a code and formatting is fully applied to this part of the code. This expression will work correct.
- formatting is applied to the part of the code. This expression will not work.
- formatting is fully applied to the part of the code, but { and } symbols are not included. This expression will not work.
- formatting does not include the { symbol that opens the part of the code. This expression will not work. 1.4.5.4
Loading the Rtf text from the data field
Loading the Rtf text from the data field Except the work with the Rtf text the RichText component loads the Rtf text from the data field. For this purpose, use the DataColumn property. All you need for this is to load the Rtf text. Select a field from the data dictionary tree. When report building the report generator will load the Rtf text automatically.
Š 2003-2008 Stimulsoft
50
User Manual
The DataColumn property This property is used for specifying from what data field will the Rtf text be loaded. Null node When you select this node the Rtf text loading from the data field is not used. Selected field Data field from what the Rtf text will be loaded. 1.4.6
System information
System information In StimulReport.Net you can find the SystemText component. It is used for system information output. Other components can show the system information but the SystemText component offers a very handy interface for setting parameters of output. The SystemText component offers three ways of information output as follow: functions, system variables, Š 2003-2008 Stimulsoft
Contents
51
expressions.
Functions This way allows to setup totals output using aggregate functions as quick as possible.
Function The drop-down list contains all available aggregate functions Data band If you want to specify by what Data band the aggregate function is to be calculated you should choose the proper Data band. Container This flag specifies that the aggregate function is to be calculated by a container. Condition This flag specifies that the aggregate function has a condition. Š 2003-2008 Stimulsoft
52
User Manual
Window for editing a condition In the text field you should set the aggregate function condition, if necessary.
System variables This way allows you to choose a system variable from the list.
System variable Drop-down list from what you can choose a system variable.
Expressions The third way allows you to edit expression in the window of expression editing. This window is the same as a window for text editing. It is used when you cannot get the result you want and updating is required.
Š 2003-2008 Stimulsoft
Contents
Expression Window for editing expression
1.5
Graphic information output
Graphic information output Introduction Imaging
54
54
Image loading
56
Image stretching Š 2003-2008 Stimulsoft
58
53
54
User Manual
Bar-codes Shapes
59
61
How to transfer an image to the StiImage component 1.5.1
61
Introduction
Introduction There are not only text but graphic components can be used in reports. StimulReport.Net supports following graphic components: the Image, the Shape, the BarCode. The Image component is used for images output. The Shape component is used for shapes output. The BarCode component is used for bar-codes output. 1.5.2
Imaging
Imaging For the report, to be more obvious, you may add images. There are logos, pictures, photos of goods, photos of your colleagues etc can be added. In StimulReport.Net for the image output you can use the Image component. This component supports the following types of images: BMP, JPEG, TIFF, GIF, PNG, ICO, EMF, and WMF.
Š 2003-2008 Stimulsoft
Contents
Š 2003-2008 Stimulsoft
55
56
1.5.3
User Manual
Image loading
Image loading If you want, using the Image component, to output an image, it must be loaded. StimulReport.Net can make it by three ways: 1. Load an image from a file; 2. Load an image from a report code; 3. Load an image from a data field. Let view all of them thoroughly.
Loading an image from a file An image can be loaded from a file. For the first, in the File property, specify the path to the file that contains an image. While report rendering, the report generator checks whether such a file does exist. If it does the report generator will load this image. After that the image will be printed.
Loading an image from a report code Sometimes you find it inconvenient to store images for report rendering in files. The report generator can save it in the report code. For this, using the Image property, you should load the image into the report code. After the image is loaded it will be saved in the report code. Important! Do not use this feature for loading images larger then 100kb. This may cause slowing down your report work.
Š 2003-2008 Stimulsoft
Contents
57
LOADING IMAGES FROM A DATA FIELD All you need for loading images from a data field is to specify the data field, from which the image will be loaded. For this purposes you may use the DataColumn property.
Š 2003-2008 Stimulsoft
58
1.5.4
User Manual
Image stretching
Image stretching Often image size does not fit (smaller) the component size. In this case vacant space can be found. Sometimes the image size does not fit (larger) the component size. In this case the Image component is to stretch the image size to fill the component with the image. For this, set the Stretch property in true.
Š 2003-2008 Stimulsoft
Contents
59
After setting the Stretch property in true the image size will fill all space of the component. When stretching, the image in proportions can be broken. To make the Image component stretch the image but to keep proportions of this image you should set the AspectRatio property in true. After this the Image component will always keep its proportions.
Important! The AspectRatio property is in process only when the image stretching is turned off.
1.5.5
Bar-codes
Bar-codes Š 2003-2008 Stimulsoft
60
User Manual
StimulReport.Net supports 22 bar-codes: EAN-8, EAN-13, UPC-A, UPC-E, UPC-Supp2, UPC-Supp5, 2 of 5 Standard, 2 of 5 Interleaved, Code 39, Code 39 Extended, Code 93, Code 93 Extended, Codabar, Code 128a, Code 128b, Code 128c, EAN 128a, EAN 128b, EAN 128c, Plessey, Msi, Postnet. For specifying the code in the bar-code you should to use the Code property.
This property is the expression. Therefore, you should specify not only the code line, but an expression for this code calculation. For example, the code is specified as a line: 1234567890123
A code from the data field: {Items.Code}
When you use the BarCode components you should know that changing of the size of the component does not result in changing the bar-code size. All bar-codes have its own standard. Many kinds of bar-codes can never be modified or can be modified within the limits. Several additional properties for bar-codes are available. You can find these properties on the Properties panel. Just roll out the bar-code type. For example, you can see the EAN-128a bar-code on a picture. This bar-code allows you to setup two options: the bar-code height and the bar-code module.
Š 2003-2008 Stimulsoft
Contents
61
Bar-code type Bar-code properties Important! Component resize does not cause a bar-code resize. Use additional options. 1.5.6
Shapes
Shapes In many reports you want to have shapes. For this, use the Shape component in StimulReport. Net. Shapes have different forms and filling brush, margin colors etc. All this can be changed. The Shape component has the following shapes: rectangle, rectangle with fillet, triangle, oval, arrow and variety of lines.
1.5.7
How to transfer an image to the StiImage component
How to transfer an image to the StiImage component The StiImage component is used to output images in the report. The way of loading of the image can be chosen using the editor of component properties. This editor can be called with double click on the StiText component or using the button of the designer calling of the Image property in the Property Editor. The following ways on how to load images to the StiImage component: 1. Load an image when creating this component in the designer. The Open button allows loading an image to the StiText component in the designer. When saving the file of a report the image will be saved with the report code. The Remove button allows deleting selected Š 2003-2008 Stimulsoft
62
User Manual
images from the designer.
2. From the data base field. Select the field of the data source and in run time an image will loaded to the StiImage object of a report.
Š 2003-2008 Stimulsoft
Contents
63
3. From variable. Create variable in the Data Dictionary with the Image type. This variable can be used in run time for working with images.
Notice. Instead of a variable, the expression which returns an image as a result, can be used. 4.4. By the internet link. Also this way work in runtime.
Š 2003-2008 Stimulsoft
64
User Manual
5. From the file. File selection allows loading images from files of images. Images of standard Bitmap types and *.emf and *.wmf metafiles are supported. The image is not serialized in code.
Also it is possible to load images from the code of application before report rendering: Š 2003-2008 Stimulsoft
Contents
65
C# StiReport report = new StiReport(); report.Load("D:\\myimage.mrt"); StiImage image = new StiImage(); image.Image = Image.FromFile("d:\\SomeImage.jpg"); report.Compile(); report["MyImage"] = image; report.Show();
1.6
Styles of components
Styles of components Introduction Font
65
65
Background Border
67
67
Horizontal alignment Vertical alignment 1.6.1
68
70
Introduction
Introduction StimulReport.Net is stuffed with many parameters for components styling. You can use font, font size, font color, background of the component, frame of the component, horizontal and vertical alignment. 1.6.2
Font
Font Using different types of fonts, changing font size, applying brushes you can make a text of any style. Font parameters can be changed in the Font property. A brush for text output can be set in the TextBrush field. For setting the font we recommend you use the Formatting buttons on the toolbar.
Š 2003-2008 Stimulsoft
66
User Manual
Font In the drop-down list you may specify the font which will be used for a text output. Font size In the drop-down list you may set the font size of the text. Bold When you press this button you set the Bold text. Italic When you press this button you set the Italic text. Underlined When you press this button you set the Underlined text. Font brush This control allows you to set the brush for the text filling. Font color palette This control allows you to set the brush color for the text filling.
Š 2003-2008 Stimulsoft
Contents
1.6.3
67
Background
Background Two brushes are used for filling the background. Use the Brush property of the component on the Borders toolbar for the background color modifying.
Fill color button This button calls the panel of the brush editing which is used for filling the background. Three types of brushes are available. They are as follow: Solid Brush, Hatch Brush, and Gradient Brush. Solid Brush – the background of the component is filled with the specified color. Hatch Brush – the background of the component is filled with the pattern. In addition you can set the background of a pattern and a pattern color. Gradient Brush – the background of the component is filled with the gradient. You should specify colors of the gradient and rotation angle of the gradient.
1.6.4
Border
Border Many components may have a border. You can make a border with different thickness, color and style. Also a shadow effect can be applied to a border. Use the Border property for control of the component border.
Border © 2003-2008 Stimulsoft
68
User Manual
Control buttons are used for setting and output of the border margin. - border for every quarter. After pressing this button border for every side of a component can be set; - no border. After pressing this button no border of a component can be found; - border on the top. After pressing this button the border on the top side of a component can be set; - border on the left. After pressing this button the border on the left side of a component can be set; - border on the bottom. After pressing this button the border on the bottom side of a component can be set; - border on the right. After pressing this button the border on the right side of a component can be set. Shadow This button is used for control of the shadow. After pressing this button, shadow of the component will appear. Border color Use of this button allows you to select the border color of the component you want. Border style This control is used for selecting the border style.
1.6.5
Horizontal alignment
Horizontal alignment Some of components allow you to set the horizontal alignment of its content in relation to their size. For example, the Text and Image components. Horizontal alignment effects on the view and position of a content and can be set to the left, right margin of a component, or can be centered, or justified (the last two ones can be applied only for the text). For alignment, use the HorizontalAlignment property of the component. Also, for alignment you can use Formatting buttons on the toolbar.
Align left Š 2003-2008 Stimulsoft
Contents
69
The component content is moved to the left. After pressing this button we set align left to all components being selected; Align center The component content is moved to the center. After pressing this button we set align center to all components being selected; Align right The component content is moved to the right. After pressing this button we set align right to all components being selected; Align width The content of the component is aligned on both left and right margins. After pressing this button we set align width to all components being selected. Notice. Align width is available only for the components which are used for a text output – Text, SystemText, ContourText.
HORIZONTAL ALIGNMENT OF A TEXT More often you use align left option. Align width allows you to get a text of the component to be aligned by width while the left and right spacing between the component and its content are equal. Align width of a text allows you to get text being justified.
HORIZONTAL ALIGNMENT OF AN IMAGE For horizontal alignment of an image component the same controls as for the Text components alignment are used. Images will be aligned only when the Stretch is False. Otherwise parameters of alignment will be ignored.
Š 2003-2008 Stimulsoft
70
1.6.6
User Manual
Vertical alignment
Vertical alignment Vertical alignment specifies the position of the content of the component in relation to the top and bottom borders of a component. Vertical alignment can be set to the top and bottom borders. For vertical alignment use the VerticalAlignment property of the Text component. For control of the vertical alignment we recommend you use Formatting buttons on the toolbar.
Align top The content of the component is moved to the top border of the component. When you press this button you set all components to be aligned top vertically; Align center The content of the component is moved to the center of the component. When you press this button you set all components to be aligned center vertically; Align bottom The content of the component is moved to the bottom border of the component. When you press this button you set all components to be aligned bottom vertically.
VERTICAL ALIGNMENT OF A TEXT By default the text component is aligned top. But if you need you can set the alignment on your own way. So if you set align bottom and the text of the component is out of component bounds then the top part of the text will not be seen. So if you set align center and the text of the component is out of component bounds then both top and bottom parts of the text will not be seen.
VERTICAL ALIGNMENT OF AN IMAGE For control of the vertical alignment of the Image component the same controls as for of the vertical alignment of the Text component are used. Images are aligned only when the Stretch property is False. Otherwise parameters of alignment will be ignored. Š 2003-2008 Stimulsoft
Contents
1.7
71
Report
Report Introduction
71
Report rendering Report code
71
72
Programming language of a report
75
Integration of the report code to VisualStudio.Net 1.7.1
76
Introduction
Introduction In StimulReport.Net the report sample is divided into pages. Every page may have its own size and print field. All components in the report are placed on pages. When report building, StimulReport.Net consistently processes all report pages. 1.7.2
Report rendering
Report rendering Unlike many report generators in StimulReport.Net the report template is divided into pages. Every page may have its own size and field of print. All components in a report are placed on pages. When report building StimulReport.Net consistently processes all report pages.
Š 2003-2008 Stimulsoft
72
User Manual
Such a structure gives more flexibility to report building. When a page is printed, some pages cannot be printed or on the contrary. You can change the order of pages being printed. You can make interrelations between pages of a report. Using the SubReport component there is no need to refer to outer reports because the SubReport report in StimulReport.Net can also be one page of a report. 1.7.3
Report code
Report code When you create a new report its source code is generated automatically. Often this code is a report script. For code generation the C# or VB.Net programming languages are used. Concurrently you can use only one of the specified programming language. In the report code the report class, inherited from the StiReport class, its structure and initialization are described. When adding new pages, components or changing any parameters of the report changes are put in the class. The report class contains description of all components, data, events, report properties, data source structure. Also all events specified by the user are added to the report code. When writing events or another code in the report you may use the standard syntax of the .Net Framework programming languages. Notice. The report code is generated on the C# or the VB.Net programming languages. So all events and any other type of code are to be written on one of these languages. While report rendering, compilation of the class being got occurs first. After that compiled report is run for execution. Š 2003-2008 Stimulsoft
Contents
73
Notice. The report code is compiled with the .Net Framework compiler. If you want to see the report code you should click the ÂŤCodeÂť bookmark in the designer.
StimulReport.Net offers you edit the report code. But you should remember that it is impossible to make changes in the automatically updated report code. Automatically updated report code is enclosed in front-end processor directives: beginning of text #region StiReport Designer generated code - do not modify Automatically updated report code end of text #endregion StiReport Designer generated code - do not modify
Š 2003-2008 Stimulsoft
74
User Manual
Important! Do not change front-end processor directives or the automatically updated report code. Sometimes you need to change all the report code without report creation again. For the new report code generation you should choose File | Report Setup. In the window press Generate New Script.
The list of programming languages The list shows all supported programming languages. Blue programming language is the programming language of this report. New report code generation After pressing this button a new report code for will be generated.
Š 2003-2008 Stimulsoft
Contents
1.7.4
75
Programming language of a report
Programming language of a report By default the report generator uses only one programming language for report code generation. It is used for automatic report code generation, for report events writing. If the current programming language of a report, by some reasons, is not fit your demand you can change it. For this choose «File | Report Setup», then choose in the «Language» new programming language. After pressing «Ok» the current programming language will be changed. Important! The new report code will be generated for the whole report and all changes which have been done in the report code will be lost. It is not convenient to change the programming language after report creation. Therefore you can can be change the programming language by default. For this you should use the Configurator utility. All programming languages in StimulReport.Net are located in the Languages folder. The language which, in the tree of services, is higher than the other one is the default programming language. For example, on the picture below the C# programming language is the default programming language. If you would like to have the VB.Net programming language as a default programming language you should drag the StiCSharpLanguage service on one position down.
© 2003-2008 Stimulsoft
76
User Manual
Supported programming language Programming languages supported by the report generator Programming language by default When report creating, the first programming language in the tree of services will be used as a programming language by default. Buttons for control of position If necessary to change the programming language by default you should use these buttons.
1.7.5
Integration of the report code to VisualStudio.Net
Integration of the report code to VisualStudio.Net For auto generation of a code standard languages are used in .Net Framework. When you use the C# programming language you can use the same code in VisualStudio.Net. The same can be said in relation to VB.Net.. So the report code can be saved and integrated to Š 2003-2008 Stimulsoft
Contents
77
VisualStudio.Net project. For saving a code use File | Save Report As‌
Notice. The report code is fully compatible with C# and VB programming languages. Therefore the report code can be saved and integrated to VisualStudio.Net project.
Š 2003-2008 Stimulsoft
78
1.8
User Manual
Bands
Bands Introduction
78
Types of bands Bands output Data bands
79
82
83
Page bands 100 Reports with Grouping 105 Reports with columns 113 Two bands output on one band 130 Data strings numbering 131 1.8.1
Introduction
Introduction Š 2003-2008 Stimulsoft
Contents
79
StimulReport.Net is the report generator that builds reports using bands (sometimes bands are called sections). A band consist of two parts: band header and working area. On the band header the band name is displayed. Also on the band header other information can be displayed. Every band is a container and may contain other components. Position of a component on the band is calculated in relation to the top-left corner of the band content. Structure of a band.
Band header Band working zone Bands have no graphic. They are not outtyped after report rendering. Only components on the band are outtyped. Band properties control only of a band position in the rendered report. Usually a report consist of many bands with text and images on them. When report rendering, bands with components in them are being copied as many times as it is required. For example, the Header band output occurs in the beginning of a data output. And the Data band output occurs for every data string. 1.8.2
Types of bands
Types of bands Thee are a lot of band types in StimulReport.Net. Each type has its specific abilities. All bands, in its turn, are divided in two categories: simple bands and cross-bands. Cross-bands cannot be positioned on a page but they can be positioned on simple bands. Simple bands list and description see below:
Simple bands Simple bands are base elements for report building. In the following table you will find all simple bands. Simple bands for report creation.
Š 2003-2008 Stimulsoft
80
User Manual
Icon
Name ReportTitleBand
Description Printed once in the beginning of a report
ReportSummaryBand
Printed once in the end of a report
PageHeaderBand
Printed on the top of every page
PageFooterBand
Printed on the bottom of every page
GroupHeaderBand
Printed on the beginning of the group
GroupFooterBand
Printed on the end of the group
ColumnHeaderBand
Printed before column
ColumnFooterBand
Printed after column
HeaderBand
Printed before data
FooterBand
Printed after data
DataBand
Printed as many times as there are writings in the data source Printed after the band after what it is positioned
ChildBand
For more visual convenience all bands have their specific color. This allows you to understand the report structure without difficulties. Bands order on the page of a report template.
Š 2003-2008 Stimulsoft
Contents
Š 2003-2008 Stimulsoft
81
82
User Manual
Cross-bands Cross-bands is the second category of bands. These bands cannot be positioned on a page but can be positioned on any simple band. This allows to build very complicated cross-reports. Cross-bands list see below. Important! Cross-bands can be positioned on simple bands. They cannot be positioned on a page or in a container. Cross-bands. Icon
Name CrossGroupHeaderBand
Description Printed in the end of a group
CrossGroupFooterBand
Printed in the end of a group
CrossDataHeaderBand
Printed before data
CrossDataFooterBand
Printed after data
CrossDataBand
Printed as many times as there are writings in the data source
Unlike simple band, cross-band header is on the bottom of the band. Bands on the Data band.
1.8.3
Bands output
Bands output When building a report all bands are shown in a definite order. This is because every band has specific functionality. For example, for a table output you should use three bands: Header, Data, Footer. The Header band is used for data headers positioning. Data are positioned on the Data band. And totals of these data are positioned on the Footer band. Š 2003-2008 Stimulsoft
Contents
Ord Name er 1 PageHeaderBand 2 ReportTitleband
83
Description On every page. Output on every page – optionally. Once in the beginning of a report. The ReportTitleBand output occurs before the PageHeaderBand output if the TitleBeforeHeader property of the page (on which both bands are positioned) is True.
3 HeaderBand, ColumnHeader 4 GroupHeaderBand 5 6 7 8 9
Once before data output (for the ColumnHeader - once for every column). Output on every page - optionally. In the beginning of every group. Output on every page optionally. DataBand For every string of data. GroupFooterBand In the end of every group. FooterBand, After all data output (for the ColumnFooter - once for every ColumnFooter column). Output on every new page - optionally. ReportSummaryBan Once in the end of a report. d PageFooterBand On every page. Output on every page - optionally.
In the table the Child band is not specified. This band is always printed after the band after which it is positioned on a page. Notice. Components out of bands are outtyped first. After them, bands are outtyped. In a report you may use as many bands of one type as you want. o example, two Header bands. There is a question - if you have used many bands of one type then which one will be outtyped first? All bands of the same type are outtyped in order of their position on a page. In other words the band which was put on a page first will be outtyped first. Then other bands will be outtyped. In the case of cross-bands the same can be said but the band on left will be outtyped first. The order of bands position can be changed. For this just drag with the mouse cursor one of bands. Also you can use Move Forward and Move Backward commands. Using buttons on the toolbar of the Layout for changing an order of components. 1.8.4
Data bands
Data bands Introduction
84
Data source for the Data band
Š 2003-2008 Stimulsoft
84
84
User Manual
Virtual Data band List output
87
88
List with header List with footer
90
92
Lists one after another output Even or odd strings filling Data sorting
95
97
Data Filtration 1.8.4.1
93
99
Introduction
Introduction There are three types of data bands: Header, Footer, Data. These bands are used for report data output. The base band is the Data band. To each Data band the data source is specified. Actually, the data source is a table. There are data fields in each data source. Having put text data with references on the band you can outtype a table. One data source can indicate, previously, unknown number of strings with data. The Data band output can occur as many times as it is specified in the data source. For example, if there is 100 lines then the Data band output will be 100 times. If, when outtyping, there is no space for all bands on one page then another page will be formed and printing will be continued. Using the Header band you adds headers to the table which output occur with use of the Data band. Correspondingly, the Footer band is used for totals of a table output. 1.8.4.2
Data source for the Data band
Data source for the Data band For building the Data band you should specify the data source that will be used. It is necessary so as the report generator must know how many times the Data band output is to be done. Therefore, in the Data band the reference to the data source is to be done. This can be done by several ways. First of all you can use the editor of the Data band. For calling the editor you may double-click on the Data band. Also you can call it from the contextual menu. The Data band editor calling with use of the contextual menu.
Š 2003-2008 Stimulsoft
Contents
85
Also the band editor may be called with use of the DataSource property of the Data band. The Data band editor allows to choose the data source as quickly as possible. The Data band editor.
Š 2003-2008 Stimulsoft
86
User Manual
If you do not want to specify the data source choose this node. Customers data source is chosen. Also you can use the button on the Data band and to choose the data source from the contextual menu. Data source changing with use of the button on the Data band.
Š 2003-2008 Stimulsoft
Contents
87
The button for quick choosing the data source. If you do not want to specify the data source choose this node. Customers data source is chosen. 1.8.4.3
Virtual Data band
Virtual Data band Sometimes you need to print Data band as many times as you want without specifying the data source to it. For this you should use the CountData property. By default this value is equal in 0. But if, for example, to set this property in 4, then the Data band will be printed 4 times. This can be used for empty columns. You should remember that if you use the Data band as a virtual the data source should not be specified. Also you can specify the number of elements using the Data band editor. Virtual Data band settings.
Š 2003-2008 Stimulsoft
88
User Manual
The field in which the number of elements for the Data band is specified. Do not specify the data source. 1.8.4.4
List output
List output Let render a report that outtypes a list. For this you should put one Data band on a page. To the band we put the data source, place Text components on the band. In each Text component we make a reference to data fields. For example: {Customers.CompanyName} The Data band setting template for the list output.
Š 2003-2008 Stimulsoft
Contents
89
Data band The Data and which forms a table. Data source The data source which is used for getting strings with data. Reference to data source The reference to the data source, from which data are to be taken to the Data band, must be specified. References to data source fields On the Data band Text components are positioned. References to data source fields are specified in them. When rendering all references will be changed on data. After report rendering all references to data fields have been changed on data from specified fields. The Data band output have been done as many times as there are writings in the data source. As a result all fields of our interest have been outtype. The template of report rendering for list output.
Š 2003-2008 Stimulsoft
90
User Manual
Print on a new page If you need to print every string on a new page you can use the StartNewPage property. Set this property in True and every data string will be printed on a new page. If the Data band has Detail bands then they will be printed after the the main band. After all Detail components will be printed, printing will be continued from a new page. 1.8.4.5
List with header
List with header Usually in reports under the every column with data there is a name of a column. For data name and other information output before data the Header band is used. It is positioned before the Data band. The template of a report with data header.
Let add the Header band. On the band we put text components. In these text components we specify data names which are on the Data band. In addition we enlarge the font height, make it bold, change the background of text components which are positioned on the Header band. Š 2003-2008 Stimulsoft
Contents
91
Rendered report with data headers.
When report rendering for one Data band you can create more than one Header band. For example, the first Header band is only in the beginning of data. But the second - both in the beginning of data and again on other pages of a report. Header bands output depend on their position on a page. Notice. For one Data band it is possible to create unlimited number of Header bands.
The PrintOnAllPages property If to see the rendered report then you can find that the report generator has showed the data header again on all pages of a report. This have been done for better visual effect of data output. But if there is no need in it such effect of a program can be changed. For this you can use the PrintOnAllPages property of the Header band. Set this property in False and you will see the header once before data. Notice. Set this property in False and you will see the header once before data.
The KeepHeaderTogether property When outtyping lists you may notice that the header is printed on one page and the first string with data on the other. For avoiding such a problem use KeepHeaderTogether property of the Data band. If this property is True then headers will always be printed with data. In other words the header and one string with data as minimum will be on one page together. If the header with the data string are out of page bounds then they will be carried over the next page.
Š 2003-2008 Stimulsoft
92
User Manual
Notice. For avoiding the header and the first string output on different pages use the KeepHeaderTogether property. Reports templates Demo, report: Simple List 1.8.4.6
List with footer
List with footer Except data and data headers data footers are used. In footers you can find variety of totals. Let view how to add a footer to the list. For this use the Footer band. This band is positioned after the Data band. By default the Footer band is printed after all data will be outtyped. Add the Footer band to the page. On the band put one text component. Suppose this text component will summarize the number of strings being outtyped. The template of a report with use of the Header and Footer bands.
When rendering the report generator adds the Footer band to the report once after all data being outtyped. Rendered report with the data footer.
Also, like the Header band, you can create unlimited number of Footer bands. Bands will be Š 2003-2008 Stimulsoft
Contents
93
outtyped in the same order as they were put on a page. Notice. For one Data band you can create unlimited number of Footer bands.
The PrintOnAllPages property Sometimes you need the Footer band will be outtyped not in the end of a report but on every page. For this use the PrintOnAllPages property of the Footer band. Set this property in true and the Footer band will be outtyped on every page. Notice. Set the PrintOnAllPages property in True and the Footer band will be outtyped on every page.
The KeepFooterTogether property When outtyping reports with lists, all data may be in bounds of one page and the footer band may be out of it. And the footer will be carried out on the next page. In this situation use the KeepFooterTogether property of the Data band. If this property is True then footers will always be printed with data together. In other words if the footer is out of page bounds and rest of data are in page bounds then the footer will be carried out on the next page with one data string. Notice. For avoiding data footer output and the last string on different pages use the KeepFooterTogether property. Samples of reports Demo, report: Simple List 1.8.4.7
Lists one after another output
Lists one after another output Often you need to have some lists being outtyped one after another in one report. StimulReport.Net has no limitation on this requirement. All you need for this is to put two Data bands on a page. Having put two Data bands specify the different data sources. Besides for every Data band create the header and the footer. For this put two Header and Footer bands. How to know to which Data band headers and footers belong? It is very simple. Put Header bands over the Data band. Put Footer – under the Data band. At that Header or Footer bands are considered to be belonged to the Data band when there are no any other Data bands between these bands. For example, two band of each type are positioned. The HeaderBand1 band is positioned over the DataBand1 band and there are no other Data bands between them. This means that the HeaderBand1 band belong to the DataBand1 band. And what about the DataBand2 band. Between this band and the HeaderBand1 band the DataBand1 band is positioned. Therefore the HeaderBand1 band does not belong to the DataBand2 band. The FooterBand1 band is positioned under the DataBand1 band and there are no other Data bands between them. This means that it belongs to the DataBand1. And the Š 2003-2008 Stimulsoft
94
User Manual
FooterBand2 is positioned under the DataBand1 band and the DataBand2. But between the DataBand1 and the FooterBand2 band the DataBand2 band is positioned. Therefore the FooterBand2 belongs to the DataBand2 band. The template of a report for two lists one after another output.
The first Data band is used for the first list output. When the list output is done completely then the second list output occurs. The second band is used for the second list output. The number of one after another lists outputs is unlimited. Rendered report with two lists.
Š 2003-2008 Stimulsoft
Contents
95
Samples of reports Demo, report: Two Simple Lists 1.8.4.8
Even or odd strings filling
Even or odd strings filling For making your report look professional and improving visual effect StimulReport.Net has the ability to alternate filled strings with unfilled. For this purpose you may use the highlight condition of the Text component. Let view the template of report rendering with filling even strings. Create a report. Put the Data band on the page and specify to it the data source. Then, on the Data band, put the Text component so as to take all band’s space. The report template for even strings filling.
Then set the condition for the Text component. In order to this every even or odd string will
Š 2003-2008 Stimulsoft
96
User Manual
be filled with specified color. For identification which string is even or odd use the Line variable like. See the example: (Line & 1) == 1
The form for editing the conditional formatting.
In other words our condition is true for every odd string. Specify the Background color for filling the component background. The report template with even or odd strings filling.
Š 2003-2008 Stimulsoft
Contents
97
Now all you need to do is to put components with data over the Text component. The template of a report with even or odd strings filling.
Notice. For increasing capacity you can set, in the window of preview, the highlight condition for every component on the band. 1.8.4.9
Data sorting
Data sorting Frequently data, which are used for the report rendering, are not sorted on the way that does not to meet your requirements. In this case it is possible to sort data with use by abilities of StimulReport.Net. Sorting can be set for every Data band separately. For sorting setup you should use the Sort property of the Data band. It is allowed to sort by five columns concurrently. For every column you can specify the order of sorting. Sorting can be made by increase or by decrease. Data sorting setup with use of the Data band.
Š 2003-2008 Stimulsoft
98
User Manual
In StimulReport.Net you can sort data by columns from parent link. For this all you have to is to specify field from the parent data source. It can be made when the Sort property setting. Do not forget that the link is to be between data sources, specified for the Data band, and your data source. Choosing the field from the data sources list.
Š 2003-2008 Stimulsoft
Contents
99
Notice. In StimulReport.Net you can sort data by columns from parent link. 1.8.4.10 Data filtration
Data filtration When rendering a report sometimes, in your report, you need not to use all data strings from the data source. In this case you filter them. The Data band has two properties which allows to make filtration by a certain condition. These properties are: Filter and FilterOn. For this, the Data band has two properties: FilterOn and Filter. The FilterOn property allows to enable or disable filters for the band. In the Filter property you can specify the condition of strings output. For example: {Customers.CompanyName.Substring(0, 1)=="A"}
- allows you to have output the clients which name starts with A. Besides the use of the filter the condition can be specified with the event. For this you can use the BeforePrint event. This event appears before component printing. In this event you must write the code that will enable or disable the Data band and printing by certain condition. If the condition is true then the Enabled property of the Data band is to be true. Otherwise we set the Enabled property in false. For example: if (Customers.CompanyName.Substring(0, 1) == “A�)then DataBand1.Enabled = true; Š 2003-2008 Stimulsoft
100
User Manual
else DataBand1.Enabled = false;
1.8.5
Page bands
Page bands Introduction 100 Page Header 100 Page Footer 102 1.8.5.1
Introduction
Introduction Page bands are used for output of the information on every page. There are two page bands: PageHeader and PageFooter. Bands are used for output of the header and footer of the page. The PageHeader band is a page header. It is positioned only on the top of the page. Бэнд PageFooter band is a page footer. It is positioned only on the lower part of the page. 1.8.5.2
Page header
Page header Use the PageHeader for output of any information on every page of a report. This band is used for the page header output. The PageHeader band is positioned on the top of a page and its output occurs once on every page of a report. This band is used for number of pages, date of the report creation etc. output. In other words it can be any information output on every page. StimulReport.Net has no limitation in number of PageHeader bands. You can put one, two and more headers. Notice. You can put one, two and more PageHeader bands on one page. Let build a report with use of the PageHeader band. Create two Data bands for data output and the Header band for headers of data output. Then put the PageHeader band. This band will be used for the number of the current page output and the total number of pages in the report output. For this create the text component on the PageHeader band and in its text expression specify the expression for your information output: {PageNofM}
© 2003-2008 Stimulsoft
Contents
Run this report for execution. On the top of every page the page number can be seen.
Š 2003-2008 Stimulsoft
101
102
User Manual
The PrintOnFirstPage property Using the PrintOnFirstPage property you can indicate the report generator whether it is necessary to outtype the page header on the first page. By default this property is True. In other words the page header will be outtyped on the first page. In order to ban the value output set the value of this property in False. In this case the page header will be outtyped on all pages of a report except the first one. 1.8.5.3
Page footer
Page footer Š 2003-2008 Stimulsoft
Contents
103
For output of the information on bottom of every page use the PageFooter band. The PageFooter band is positioned once on the bottom of every page. StimulReport.Net has no limitation on the number of PageFooter bands. This band is used for number of a page, totals output etc. Notice. Unlimited number of PageFooter bands can be positioned on one page. Let build a report with use of the PageFooter band. Create two Data bands on a page for data output and the Header band for headers output. Then put the PageFooter band. You should know that in the report designer the PageFooter band is being docked to the bottom of a page. This is its own distinguishing feature, because other bands are docked to the top of a page. Important! In the report designer the PageFooter band is docked to the bottom of a page. This band is used for the current page number and the total number of pages in the report output. Create the SystemText component choose the PageNofM system function: {PageNofM}
The template of the report rendering with the page footer.
Š 2003-2008 Stimulsoft
104
User Manual
After rendering of every page on their bottom you can see the page number and total number of pages in the report.
Š 2003-2008 Stimulsoft
Contents
105
The PrintOnFirstPage property Using the PrintOnFirstPage property you can indicate the report generator whether it is necessary to outtype the page footer on the first page. By default this property is True. So the page footer will be outtyped on the first page. If you want to ban the value output for this property set the value of this property in False. In this case the page footer will be outtyped on all pages except the first one. 1.8.6
Reports with grouping
Reports with grouping Introduction 106
Š 2003-2008 Stimulsoft
106
User Manual
Condition of grouping 107 Group Header 108 Group Footer 109 Whole group output 110 New page formation 110 Group Headers output only 111 Nested groups 111 Totals of a group 112 Strings numbering in a group 113 Grouping in the multicolumn reports 113 1.8.6.1
Introduction
Introduction One of the most important tasks in report building is grouping of data. Grouping can be applied either for logic strings with data on a page separation or for making your report look visually better. For rendering reports with grouping use two bands: the GroupHeader and the GroupFooter bands. The GroupHeader bands are put in the beginning of each group. The GroupFooter band is positioned in the end of every group. The template of a report with grouping.
Š 2003-2008 Stimulsoft
Contents
1.8.6.2
107
Condition of grouping
Condition of grouping You should specify the condition of grouping for report rendering. In accordance to this condition all strings with data will be divided into groups. For example, if the list of companies is to be output then this list can be divided into groups in alphabetical order. In other words companies which names start with A are in the first group. Companies which names start with B are in the second group etc. In this case the condition for these groups is the first letter of the company name. You should remember that the report generator, before grouping, does not sort strings with data automatically. That is why you should specify sorting yourself. In our case the list of companies must be sorted by the column which contains company names. Otherwise grouping is not correct. Important! You should remember that the report generator, before grouping, does not sort strings with data automatically. That is why you should specify sorting yourself.
Š 2003-2008 Stimulsoft
108
User Manual
The condition is specified in the designer of the GroupHeader band. Any value can be a condition. For example, you can group the list of companies by the principal addresses. And in this case a condition in a column is found from the database. Strings grouping by criterion.
1.8.6.3
Group header
Group header Group header is created with use of the GroupHeader band. The GroupHeader band is the base band for reports with grouping rendering. It is impossible to make grouping without this band. On the group header components for information output are positioned. For example, this is group name, date, condition of grouping etc. The GroupHeader band is output once in the beginning of every group. For grouping creation you should specify a condition. The condition of grouping is specified with use of the Condition property of this band or with of the designer of the GroupHeader band. Notice. The Header band is always output over the GroupHeader band. And bands positions on a page in the designer do not matter. The report with the group header.
Š 2003-2008 Stimulsoft
Contents
109
When report rendering the report generator links the group header and the specified Data band. The GroupHeader band is positioned on a page over the Data band which outputs strings with data. The GroupHeader band is always belongs to a certain Data band. Usually this band is the first Data band which is positioned under the GroupHeader band. For report with grouping rendering it is necessary to have the Data band. Important! For report with grouping rendering it is necessary to have the Data band. It is necessary to have the Data band because strings with data are output with use of this band. And these stings with data are the base of grouping. Also you may specify the strings sorting in the Data band. The data sorting has effect on the building of grouping order. 1.8.6.4
Group footer
Group footer For group footer output the GroupFooter band is used. This band is positioned after the Data band. And all this is about the Data band with what the GroupHeader band is linked. Every GroupFooter band belongs to the GroupHeader band. The GroupFooter band will not be output without the GroupHeader band. Notice. The GroupFooter band is always output before the Header band. The report with the group footer.
Š 2003-2008 Stimulsoft
110
User Manual
The GroupFooter band is used for different information output by the group. For example, if you want to output the number of strings in a group it is enough to output the text component on the GroupFooter band. Specify the following expression in the text component: {Count()}
1.8.6.5
Whole group output
Whole group output When report with grouping rendering some groups cannot be positioned on one page. In other words a part of strings output will be continued on another page. For avoiding this you may make the report generator to output groups together. All you need for this is to set the KeepGroupToghether property of the Data band to which the Group Header band belongs in True. If the report generator is not able to output the whole group on one page then all the group is carried out on the next page. If the next page space is not enough for the whole group output then this group is split and output on some pages. 1.8.6.6
New page formation
New page formation If you want to have one group on one page it is enough to set the StartNewPage property of the GroupHeader band in True. If this property is True then every group in the report will be positioned on one page. If information of the group cannot be positioned on one page then the information output will be continued on the next page. At that the next group output will be on the new page. Š 2003-2008 Stimulsoft
Contents
1.8.6.7
111
Group footers output only
Group footers output only Usually, in reports with grouping, either groups only or headers and footers concurrently are used. But what to do if in your report you need to make group footers output only without group headers? For creation report with grouping it is necessary to use the GroupHeader band. But we do not want to outtype it after rendering. In this case you should set the GroupHeader band's height in 0. The report will be rendered successfully and the GroupHeader band will not be outtyped because of its height is 0. The GroupHeader band with the height equal in 0
1.8.6.8
Nested groups
Nested groups When reports rendering you may use more than one grouping. For this you should put the required number of GroupHeader bands before the DataBand. After the Data put either the same number of GroupFooter bands or less. To each GroupHeader band you should specify the criterion of grouping. When rendering GroupHeader bands are processed in order of their position on a page – top-down. The topmost band is processed first then the one beneath etc. When GroupFooter bands positioning you must remember that the last GroupFooter band corresponds to the first GroupHeader band.
Š 2003-2008 Stimulsoft
112
User Manual
It is recommended to have equal numbers of GroupHeader and GroupFooter bands. If the number of GroupFooter bands is higher than GroupHeader bands then GroupFooter bands which are positioned lower than other ones will be used. Other bands will be ignored. If the number of GroupFooter bands is less than GroupHeader bands then the lowest GroupHeader bands which are positioned closer to the Data will be output without footers. Important! We recommend you to have equal number of GroupHeader and GroupFooter bands in you report. 1.8.6.9
Totals of a group
Totals of a group For calculation totals of a group it is enough to put the text component with the aggregate function on the GroupHeader band or the GroupFooter band. For example, for calculation of number of strings in each group you must write the following expression in the Text component: {Count()}
The component is placed on the GroupFooter band. After rendering you can see that on the bottom of every group the calculation of number of strings is done. Š 2003-2008 Stimulsoft
Contents
113
1.8.6.10 Strings numbering in a group
Strings numbering in a group For strings numbering in a group we recommend you use the Line system variable. The reference to this variable is specified in the text component expression. The text component is positioned on the Data band. For example, let put a text component on the Data band and write the following in its expression: {Line}
After report rendering we shall get the numbered list of strings in every group. Numbering starts with 1. In a new group numbering starts again. If necessary to make through-numbering you should apply the LineThrough system variable. For this you must change the expression in the text component: {LineThrough}
As a result through-numbering of all strings in a group is done. 1.8.6.11 Grouping in the multicolumn reports
Grouping in the multicolumn reports You can use grouping in reports with columns. But there is a limitation. Grouping output occurs only when you use the output columns on a page mode. In case of with columns on the band there can be any unpredictable results. There are no any limitations in usage of grouping in columns on a page. Important! In reports with grouping you cannot use columns on a band. 1.8.7
Reports with columns
Reports with columns Introduction 114 Columns on a Page 114 Columns on the Data Band 117 Across Then Down column output mode 118
Š 2003-2008 Stimulsoft
114
User Manual
Down Then Across column output mode 120 Minimal number of strings in a column 123 Column headers 124 Column footer 126 Headers and footers combination 127 1.8.7.1
Introduction
Introduction StimulReport.Net has the ability to group data in columns. Data output in columns allows you to improve your report view and more rationally use the page space. Two types of columns output are supported: columns on a page and columns on the Data band. In its turn columns output on the Data band supports two modes - Across Then Down and Down Then Across. So StimulReport.Net offers full set of tools for building reports with columns. 1.8.7.2
Columns on a page
Columns on a page On the report page you can put data in columns. To turn on the mode of data output as columns use the Columns property of a report page. By default this property is equal in 0. If to set this property in 1 then data will be output as columns. Besides you should know that t is necessary to change some more two properties - the ColumnWidth and the ColumnGaps. In the ColumnWidth property specify the column width. This width is true for all columns which will be output on a page. In the ColumnGaps property specify the interval between two columns. Notice. For setting the page for some columns output you should set two properties of the page. In the Columns property specify the number of columns. In the ColumnWidth property specify the every column width. Columns parameters.
The first column width The second column width Š 2003-2008 Stimulsoft
Contents
115
The interval between two columns In the column output mode on a page the page as if is split vertically on some little pages. And the report in output logically from the beginning of the first part, then the second one is output etc. Notice. The number of columns on a page is unlimited. The example. Build a report with two columns. Set the Columns property in 2 (this means two columns). Specify the column width in the ColumnWidth property and in the ColumnGaps property – the interval between columns. Then put two bands on a page - the Data band and the Header band. On the Header band the data name will be output. On the Data band data will be output. Notice. Column borders are specified with red line. The template of a repot with some columns output.
Run the report. As you can see on a picture there are two columns on a page. All lines are numbered. The rendered report with two columns output.
Š 2003-2008 Stimulsoft
116
User Manual
Column of a report output occurs as follow. StimulReport.Net prints bands until the column space is over. After this instead of the new page formation the report generator adds the right new column, and then continues to print data from the top of a page and so on and so forth until the page space is over. The direction of a report with columns on a page.
Š 2003-2008 Stimulsoft
Contents
117
Report samples Demo, report: Multi-column list 1.8.7.3
Columns on the data band
Columns on the data band Columns output on the page has one imperfection. Data can be enough only for one column. As a result other columns will stay unfilled. That results in incorrect usage of the page space. For avoiding this problem you can use the Data band. To turn on the mode of data in columns output you should use the Columns property of the Data band. Set 1 to this property. As you remember the chapter Columns on the page you should set two properties - ColumnWidth and ColumnGaps. In the ColumnWidth property you specify the column width. This width is true for columns which are to be put on the Data band. In the ColumnGaps property you specify the interval between two columns. Notice. For the Data band setting for a few columns output you have to set two properties of the Data band. In the Columns property a number of columns is to be specified. In the
Š 2003-2008 Stimulsoft
118
User Manual
ColumnWidth property you specify the width of every column. Columns parameters.
The first column width The second column width The interval between two columns Notice. You can create the unlimited number of columns on a page. Columns on the Data band can be selected by two modes: AcrossThenDown and DownThenAcross. 1.8.7.4
Across Then Down column output mode
Across Then Down column output mode In this mode strings are output logically on the Data band from left to right. And strings output is – one string in one column. When all strings will be output in columns on the Data band then a new Data band will be formed and again all strings in columns will be output. So data, being output using columns, take space of a page necessary for these data. Order of report rendering with column output in the Across Then Down mode.
Š 2003-2008 Stimulsoft
Contents
119
Notice. The number of columns for output on the Data band is unlimited. Build a report with columns. Create three columns on the Data band. For this, create two bands - the Data band and the ColumnHeader band. Then set the Columns property in 3 (that means three columns). Specify the column width in the ColumnWidth property and specify the gap between columns in the ColumnGaps property. On the ColumnHeader band put text components. Column names will be output here. On the Data band data will be output. Notice. Column borders are indicated with red vertical line. Besides all components which are positioned in the first column, when editing, are shown in other columns. The template of a report with some columns output on the Data band.
Š 2003-2008 Stimulsoft
120
User Manual
Run the report. Seeing the number of strings you can find the direction of columns output in the report. Rendered report with output in three columns in the Across Then Down mode.
1.8.7.5
Down Then Across column output mode
Down Then Across column output mode Across Then Down column output mode has a weakness. It is convenient to read the information on a page because data are output from left to right and down. It is much better to have the column output provided with the Down Then Across mode. This mode differs from the Across Then Down mode – the column is output entirely, then the second column is output entirely etc.
Š 2003-2008 Stimulsoft
Contents
121
The direction of report rendering with column output in the Down Then Across mode.
In the Down Then Across band the report generator tries to distribute all strings among available columns. Then, after distribution, the report generator starts the first column output. At that the column is not output to the end of a page but to put the number of elements for this column. After the first column output the second column output starts etc. So data, being output using columns, take space of a page necessary for these data. Besides, data will be distributed almost equally among columns (unlike column output on a page). All data will be represented in convenient for reading form. Notice. The number of column being output on the Data band is unlimited. Render a report with column output in the Down Then Across mode. Create two bands on a page - the Data band and the ColumnHeader band. Then set Columns property in 3 (this Š 2003-2008 Stimulsoft
122
User Manual
means three columns). In the ColumnWidth property specify the column width and in the ColumnGaps property - the interval between properties. Notice. Column borders are specified with red vertical line. All components positioned on the first column, when editing, are projected on the other columns. The template of a repot with some columns output in the Down Then Across mode on the Data band.
Run the report. The report generator equally arranged strings among these three columns. In the first column 31 strings could be placed. In the second column 31 strings could be placed. In the third column 29 strings could be placed. All information on a page is not convenient for reading. The rendered report with two columns output in the Down Then Across mode.
Š 2003-2008 Stimulsoft
Contents
1.8.7.6
123
Minimal number of strings in a column
Minimal number of strings in a column Using the Down Then Across mode of columns output you can meet the following situation. In a report there is В отчете выводится слишком мало строк, к примеру пять. At that data are equally arranged between all columns. In some cases it is necessary for the report generator do not arrange equally strings with data between columns. For improving © 2003-2008 Stimulsoft
124
User Manual
visualization it is better for data strings be outtyped in one column. The data in column output with minimal number of strings.
For this case the MinRowsInColumn property of the Data band is used. In this property the minimal number of strings in the first column can be specified. By default this property is equal in 0. This means that control of the minimal number of strings is not in process. If the value of this property is higher than 0 then, in the first column, no less than specified number of strings will be shown. The data output in columns with minimal number of strings. The MinRowsInColumn value is 5.
1.8.7.7
Column headers
Column headers Usually, you use the Header band for headers output. But the ColumnHeader band is a specific one for columns. What is the difference between them? The Header band is put once before the Data band. The ColumnHeader band is put once too. But components on this band can be put again under the every column. Besides the ColumnHeader band is used only for the columns positioned on the Data band. Š 2003-2008 Stimulsoft
Contents
125
Notice. The ColumnHeader band is used only for columns positioned on the Data band. For columns on a page the Header band has the same functionality. Example. Create two Data bands and the ColumnHeader band. In the Columns property specify three columns for the Data band. Specify data for the ColumnWidth property. After that put the text object with the Data text on the Data band. On the ColumnHeader band put the text object with the Header text. Do not forget that red dotted lines shows the column border. The template of a report with use the ColumnHeader band.
Run the report. The Header text has been repeated over the every column. So it is enough to create the column header and it will be repeated over the every column. Rendered report with use of column headers.
The PrintIfEmpty property And what should you do if the number of strings with data is fewer than the number columns? In this case you will be the same number of headers outputs as the number of columns outputs. If there are two columns, then two headers output will be done.
Š 2003-2008 Stimulsoft
126
User Manual
And what should you do if it is necessary to output the same number of headers as the number of columns on a page without considering the number of strings. In this case you may use the PrintIfEmpty property of the ColumnHeader band. If you set this property in true then you can make the header always be output. Important! You should remember that when you use the Down Then Across mode and use the MinRowsInColumn property, the report generator is not able to indicate the number of strings precisely. Therefore using the MinRowsInColumn property set the PrintIfEmpty property in True. 1.8.7.8
Column footer
Column footer For output of columns positioned on the Data band the ColumnFooter band is used. The ColumnFooter band output occurs once under the column. All components positioned on this band will be shown under every column. Notice. The ColumnFooter band is used only for columns on the Data band. For columns on a page the Footer band also has a certain functionality. For example, create two bands on a page - the Data band and the ColumnFooter band. Specify three columns for the Data band with use of the Columns property. Also fill the ColumnWidth property. On the Data band put the text object with the Data text. On the ColumnFooter band put the text object with the Footer text. Do not forget that red dotted line is the column border. The template of the report with use of the ColumnFooter band.
Render the report. The Footer text is under every column.
Š 2003-2008 Stimulsoft
Contents
127
Rendered report with use of column headers.
The PrintIfEmpty property If the number of strings with data is less than the number of columns then the band output will occur as well as column headers output. So there will occur as many footers outputs as columns outputs. If you need to output the same number of columns as the number of columns on a page without considering the number of strings then you have to use PrintIfEmpty property of the ColumnFooter band. When you set this property in True then the column footer is always being output. Important! You should remember that if you use the Down Then Across mode then, when using the MinRowsInColumn property, the report generator is able to indicate the accurate number of columns. Therefore, using the MinRowsInColumn property set the PrintIfEmpty property in True.
1.8.7.9
Headers and footers combination
Headers and footers combination When outputting headers and footers for columns on a page it is very important to know what is the order of bands’ position on the page? Create a report in which many Header, Footer, ColumnHeader, ColumnFooter band and one Data band will be used. Place all header and footer bands at random order. Then draw attention to bands position on a page, their outtyping in different modes of columns output. The template of a report with many header and footer bands combination.
Š 2003-2008 Stimulsoft
128
User Manual
Across Then Down column output mode In the Across Then Down mode all header bands are output in order of their position in the report template. In our case the Header1 band will be output first. Then the ColumnHeader1 band three times over the every column. And then – the Header2 band and over the every column the ColumnHeader2 band. Bands output in order of their position on a page allows you to combine both types of header bands for getting the result you want. Footer bands are output a bit differently. The ColumnFooter are output first. Then the Footer bands in case if all strings with data were output. But if the Footer band’s PrintOnAllPages property is true then band are output in order of their position on a page. You should remember that if the PrintOnAllPages property of the Footer band is not True then this band will be output only after all strings output. It is necessary to remember when report rendering. The rendered report with columns output in the Across Then Down mode.
© 2003-2008 Stimulsoft
Contents
129
Down Then Across column output mode In this mode the header bands output is the same as in the Across Then Down mode. In other words bands are output in the order of their position on a page. You should remember that if the PrintOnAllPages property of the Footer band is true then all footer bands will be output only in order of their position on a page. If the PrintOnAllPages property of the Footer band is not set then only ColumnFooter bands are outtyped. In this case Footer bands are ignored. The rendered report with columns totals output in the Down Then Across mode.
Columns output on a page When outputting columns on a page the ColumnHeader band is the equivalent of the Header band and the ColumnFooter band is the equivalent of the Footer band. There is definition Š 2003-2008 Stimulsoft
130
User Manual
between them. The ColumnHeader and ColumnFooter band are output for every column. All bands are output in the order of their position on a page. 1.8.8
Two bands output on one band
Two bands output on one string Do not know how to do this? For solving this problem you should use the Child band. Let create a new report. After that put the Data band. Below the Data band put the Child band. The template of a report with use of the Child band.
Run the report. As you see in the sample the Child band was outtyped as many times as the Data band. In other words the Child band is a part of the Data band, but, nevertheless, keeps all band's properties. Rendered report with use of the Child band.
Š 2003-2008 Stimulsoft
Contents
131
You should know that this band can be used not only with the Data band. It can be put after any type of bands on a page. For example, after the Header band or after the GroupHeader band. The Child band can be used jointly with any types of bands on a page.
1.8.9
Data strings numbering
Data strings numbering In addition to data and data headers, data footers are used. In footers variety of data can be put. Let see how to add a footer to the list. For this use the Footer band. This band is positioned after the Data band. By default the Footer band is printed once in a report right after all data being printed. Let add the Footer band to a page. On the band we put the text component. Suppose this text component will summarize the number of outtyped strings. Š 2003-2008 Stimulsoft
132
1.9
User Manual
Containers
Containers Introduction 132 Bands positioning in a container 133 Containers position 134 Using the StartNewPage property 135 Side by Side reports 135 Multiple tables on one page output 136 Cloning 137 1.9.1
Introduction
Introduction Container is a rectangular area in what component,. including bands, can be contained. When moving a container then all components in it are being moved too. A container may be positioned either on a band or on a page. This allows you to have various abilities in report creation. Containers on a page
Š 2003-2008 Stimulsoft
Contents
1.9.2
133
Bands positioning in a container
Bands positioning in a container A container can be positioned on a page, in another container, and on a band. Almost all components of a report can be positioned in the container. But not all bands can be positioned in the container. In the following table (see below) you can find a list of bands with indication where these bands may be positioned. Bands positioning in a container Band Name
Š 2003-2008 Stimulsoft
Positioning of a band in a container
ReportTitle
No
ReportSummary
No
PageHeader
No
PageFooter
No
134
User Manual
GroupHeader
Yes
GroupFooter
Yes
Data
Yes
Child
Yes
Header
Yes
Footer
Yes
As you can see in the table report bands and page bands cannot be positioned in the container. The rest of bands can be positioned in the container and can be used in report rendering. 1.9.3
Containers position
Containers position In reports you can meet three types of containers position: on a page, on a band, and in another container. Let view these types.
Positioning on a page The first type - position of a container on a page. The main purpose is organizing several independent streams of printing. At that containers can be positioned on any part of page. Every container is a small page. In other words containers allows to place a few small pages with its bands and components on one page. So you can build many complicated reports. Notice. The of containers positioned on one page is unlimited.
Positioning on a band This type has considerable limitation. Container cannot contain bands. In this type the container can be used only for positioning components for information output. Important! If the container is positioned on a band then it cannot contain bands.
Positioning in a container This types describes positioning of a container in another container. This type is mixture of two types described above. So if the container is positioned in another container that, in its turn, is not positioned on a band, then the container can contain bands. So if the container is positioned in another container that, in its turn, is positioned on a band, then the container Š 2003-2008 Stimulsoft
Contents
135
cannot contain bands. 1.9.4
Using the StartNewPage property
Using the StartNewPage property Concerning pages, usage of the StartNewPage property has some distinctions. Using this property with components which are placed in the container, a new page is not formed. Controlling is transmitted to the next container. If this is the last container then a new page will be formed. 1.9.5
Side by Side reports
Side by Side reports On of the report types which can make report creation more quicker is Side by Side report. In such a type of a report two list of strings are outtyped. Beside both list are absolutely independent from each other. Usually, for creation of a such a report it is necessary to use SubReport. StimulReport.Net has this ability too. But, using containers, such a report can be built very quickly and without difficulties. Containers positioning in the Side by Side report.
Š 2003-2008 Stimulsoft
136
User Manual
Let create the Side by Side report. Insert two containers on a page. The Dock property of one of them we set in Left. The Dock property of the second one we set in Right. It is necessary for containers to be docked to page borders and took all space available by the height. If there is no need in it you may not do it. Between containers we set a space so as to separate two lists. Now in the first container we create Header and Databands. Using these bands the first list output will be done. As a result after report rendering you will see two lists. The Side by Side report template.
1.9.6
Multiple tables on one page output
Multiple tables on one page output There are reports in which it is necessary to have multiple tables on one page. And, besides, tables are to be positioned in any part of page. Most often one build such a report using the SubReport. But there is no difficulties in building such a report with use of containers. All you need is to put container is their positions and put all necessary bands.
The template of a report with multiple tables on one page.
Š 2003-2008 Stimulsoft
Contents
1.9.7
137
Cloning
Cloning StimulReport.Net has the unique Clone component. This component is used for cloning of a part of a report into the specified part of the report. Only the content of the component can be cloned. For understanding the cloning create a report. Put a container on a page. Put two bands for list output in this container. Place the container on left part of the report page. On the right side of a page put the Clone component. Then, in the report designer of the Clone component, specify the container which should be cloned. In this case specify the container that has earlier been created on the page. Container and clone components position in the report with use of cloning.
Š 2003-2008 Stimulsoft
138
User Manual
Run the report. The container will be rendered first. Then the list on the left part of the page will be output. After that the list output will be continued on the right part of the report page where the Clone component is positioned. This happens because the Clone component has cloned all bands which were positioned in the container. Using the Clone component you can create complicated reports with columns. The first column is output with use of the container. The other columns are output with use of the Clone component.
1.10
Autosizing
Autosizing Introduction 139 Automatic change of a size 139 Automatic change of a text size 140 Automatic change of containers size 141 Automatic change of bands size 142
Š 2003-2008 Stimulsoft
Contents
139
Both bands and columns size changing 143 Binding to the bottom of the component 145 Components shift 147
1.10.1 Introduction
Introduction Components, depending on the information they contain, may change their size automatically. Sometimes a written text may be out of bounds of a component. Sometimes image size is less than the component size. More often automatic change of a component size is used when you want to write a text which size is unknown. Naturally, you can choose a component size to match the text size always but the page space will be used not properly. And you have to do if the component size is less than the text size? In this case use the automatic change of a size. 1.10.2 Automatic change of a size
Automatic change of a size Using CanGrow и CanShrink properties you can control of the automatic change of a size. If the CanGrow property is True then the component will fit with an image or a text size. Automatic change of the component size according to the image size.
For example - a text or an image size is smaller then the component size. If the CanShrink property is true then the component may scale down so as to fit with the text or the image size. It helps you to escape losses of the page space. Automatic change of the component size according to the image size.
Š 2003-2008 Stimulsoft
140
User Manual
The report generator allows to set both CanGrow and CanShrink properties in True. In this case if it is required to scale up it will be executed. If it is required to scale down it will be executed too. Automatic growing of a height and automatic shrinking of a width of an image.
1.10.3 Automatic change of a text size
Automatic change of a text size Automatic change of a size of text documents differs from automatic change of a size of other components. The WordWrap property of text components have effect on changing size. If the WordWrap property is True (i.e. the multiline text is shown) then the CanGrow and CanShrink properties have effect on the component height. For example, if the text is out of component bounds then its height will be increased. Automatic growing of a height of a text component.
And, on the contrary, if there is an empty space then the report generator will shrink the height of the text component. Automatic shrinking of a height of a text component.
Also as with other components it is not allowed to set both CanGrow and CanShrink in True. In this situation the height will be shrunk or grown and it depends on the text information.
Š 2003-2008 Stimulsoft
Contents
141
Important! If the WordWrap property is True then the CanGrow and CanShrink properties have effect on the height of a text. If the WordWrap property is False then the component width is changed. For example, if the text is out of horizontal bounds and is not seen on the right then, if the value of the CanGrow property is True, the component width will be grown.
The AutoWidth property Besides the CanGrow and CanShrink properties the AutoWidth property has effect on the size changing. If to set the AutoWidth property in True then the text component will change its width that depends on the text width. The CanGrow, CanShrink and AutoWidth properties may be used at once. Automatic growing of a text component width.
1.10.4 Automatic change of containers size
Automatic change of containers size Containers cannot contain any visual information for output it in the report. Correspondingly, it may seem that the CanGrow and CanShrink properties have nothing common with it. But it is not true. Containers may contain other components which have specified sizes and positions. Depending on these component parameters (components are positioned in the container) container size can be changed. Suppose that in there are components in the container. Their position and sizes are out of container bounds. Set the CanGrow property in True. In this case, the size of the component will be grown so as to all components in this container be positioned in bounds of its size.
Automatic grow of a container size.
Š 2003-2008 Stimulsoft
142
User Manual
If the CanShrink property is True and size of all components is lesser then the containers size then the container size will be shrunk to the size of all components. Automatic shrinking of a container size.
1.10.5 Automatic change of bands size
Automatic change of bands size Bands are containers. Therefore changing of their size is the same as changing of containers size. Band size can be changed depending on components positioned on this band. But bands have the particular feature. Bands can automatically change only the height (the width for cross-bands). For example, if there is a component, which lower part is out of bounds, on the band, then, if to set the CanGrow property of the is band in True, the band height will be increased with the report generator. After increasing, the lower part of the band will concur with the bottom of the component. This means that the whole component is positioned in the band. Automatic band height growing.
Š 2003-2008 Stimulsoft
Contents
143
So if to set CanShrink property in True and there is the space between the lower part of the component and the bottom of the band then the band height will be shrunk. Automatic shrinking of the band height.
1.10.6 Both bands and columns size changing
Both bands and columns size changing Very frequently both the Text component and the Data band, on which this Text component is positioned, size changing occurs. View the example. Suppose that you want to output a text and the text size is not preset. For this create the Data band. Create the Text component, which will output the text, on this band. Set the WordWrap property of the text component in True so as not to output this text in multiple strings. The template of the report without using the automatic change of sizes. Š 2003-2008 Stimulsoft
144
User Manual
If its size is not enough to output the text on the whole then set the CanGrow property in True so as the Text component will be able to increase its height. If to run the report then you will see that the text component height is being changed but the Data band height is not being changed. As a result text components run over each other. The rendered report without use of the automatic change of sizes.
Set the CanGrow property of the Data band in True, for the Data band is able to change its height, so as all components on it are output. After this the Data band will change their sizes depending on the Text size. The rendered report with use of automatic change of sizes.
Š 2003-2008 Stimulsoft
Contents
145
How does the report generator work in this case? The calculation of Text components size is processed first. If there is need size is changed. In our example the size has been increased. After that the Data band checks all components which are positioned on it. If there are components which are out of the band bounds then the size is increased. The band height increasing after the component height increasing.
1.10.7 Binding to the bottom of the component
Binding to the bottom of the component Š 2003-2008 Stimulsoft
146
User Manual
In the previous chapter the example of changing size of both band and text component on this band was viewed. In this sample only a component changes its size. But what we have to do if some components are on one band and one component changes its size but others not. A template of a report with use of automatic change of a size.
As a result if to view the rendered report then you can see empty spaces between components. Rendered report contains empty spaces between components.
So what to do to make components change their height? For this purpose StimulReport.Net answers on a such a way. You can bind the bottom border of the component with the bottom border of the band on which this component is placed. Notice. The GrowToHeight property binds the bottom border of a component with not only the bottom border of a band but of a container too. For this use the GrowToHeight property. This property is set in True by default. If you set values of this property in true for all components which size is not changed then their bottom borders will be bind with the bottom border of the band. Š 2003-2008 Stimulsoft
Contents
147
Notice. The GrowToHeight property can also be set for component which size is changed automatically. In this case if after changing the component size its bottom border does not concur with the bottom border of band then the component size will be adjusted. After this procedure the report looks like this. A report after the GrowToHeight property had been used.
Notice. If in one band some components which can change their sizes are placed then you may set the value of the GrowToHeight property for all these components in True. As a result heights of all these components will always be adjusted to the component which height is maximal. 1.10.8 Components shift
Components shift When you build a report with use of the automatic change of a size you may meet a problem: what to do if under the component which is grown to height there is another component? If the first component will grow it will cover the component below. For preventing this use the Shift property. It is set in True by default. If the component height of the modified component is changed then all components, which top borders are below of the top border of the modified component, will be moved down without covering components below. Component height shrinking does not result in changing a position of components which are under it. Decreasing of the component height does not result in changing the position of components which are under it. The Shift property works only when the height is increasing. Š 2003-2008 Stimulsoft
148
User Manual
For example, put five components on the Data band. One of these components (further the variable component) will automatically increase its height depending on the text in it. Other four components will change their position depending on the first component increasing. View the other four components behavior. A template of a report with components placed in some rows on the Data band.
The Component1 top border concurs with the bottom border of the modified component. Therefore it will change its vertical position that depends on the modified component height. Component2 horizontally is not positioned under the modified component. But its top border concurs with the top border of the modified component. The Component2 position will be changed. Component3 horizontally is not positioned under the modified component. Its top border concurs with the top border of the modified component. But its top border is higher than the top border of the modified component. Therefore the Component3 position will not be changed. And, finally, the Component4 top border is lower than the bottom border of the modified component. Therefore the Component4 position will not be changed. Rendered report with use of the Shift property.
Š 2003-2008 Stimulsoft
Contents
149
In this template the Shift property of all components is turned on. If this property were turned off then all components would not change their position.
1.11
Calculation of totals
Calculation of totals Introduction 150 Calculation of totals procedure 150 Totals output in any part of a report 151 The type of a result of an aggregate function 151 Expressions with aggregate functions 152 Totals with conditions 154 Calculation of totals of a page and of a container 155
Š 2003-2008 Stimulsoft
150
User Manual
Calculation of totals of a column 155 Calculation of totals in a code of report events 157 Calculation of growing total 159 Invisible bands 159 Totals and automatic change of a size 159 Aggregate functions syntax 159 Calculation of totals in hierarchical reports 160 1.11.1 Introduction
Introduction In many reports it is necessary to calculate totals – sums of a page, number of strings, average value etc. For this you can use aggregate functions in StimulReport.Net. Using aggregate functions you can calculate a sum, number of strings, average values, maximal values, minimal values, to get first values from the list, to get last values from the list, to get a string by the specified range. The ranges of strings can be strings of a list, strings on one page, strings from a group, strings from a container etc. StimulReport.Net supports seven aggregate functions as follows: · Sum - returns the sum of the specified expression; · Count - returns the number of rows in the specified range; · Avg - returns the average value of the specified expression; · Min - returns the minimal value of the specified expression; · Max - returns the maximal value of the specified expression; · First - returns the first value in the specified range; · Last - returns the last value in the specified range. 1.11.2 Calculation of totals procedure
Calculation of totals procedure If you want to calculate the value of an aggregate function in StimulReport.Net you should use events of components. For successful calculation you must have three events: start of the report rendering (initialization of the aggregate function), one element of rendering (processing of one string), and the end of the report rendering (calculation of totals output). Usually, for making all calculations, the report generator uses the BeginRender, Rendering, and EndRender events of the Data band. But sometimes other situations can be. For example, if you want to calculate totals of a group you use the BeginRender and the © 2003-2008 Stimulsoft
Contents
151
EndRender events of the GroupHeader band. Also you may combine, for example, initialization and calculations in events of the Data band and use the EndRender event of a report for an output of the result of calculation. Such a scheme increases the flexibility when calculation of the aggregate functions and allows to make all calculations in one operation. 1.11.3 Totals output in any part of a report
Totals output in any part of a report Usually, components in which text expressions the aggregate function call is specified, must be put in the total band or in the Data band. If the total output is to be in the Header band it is either impossible or possible using the script. But this is not all about of StimulReport.Net. The component with the aggregate function can be put in any kind of a band. Notice. Components with aggregate functions can be put in any part of a report. Also you can put an aggregate function on a page and other pages. For example, you can calculate the sum of values in the list and show it in the header of the list. Also you may calculate the number of strings and show its value in the beginning of a page. At that there is a restriction. You should specify to which the Data band does this aggregate function belong. For this you should specify the Data band as a function argument. For example: {Sum(DataBand1, Products. UnitsInStock)}
- this expression will return the sum of values of the Products.UnitsInStock column for every string of the DataBand1 band. Considering the Count aggregate function: {Count(DataBand1)}
- this expression will return the number of strings of the DataBand1 band. 1.11.4 The type of a result of an aggregate function
The type of a result of an aggregate function All aggregate functions returns the value of the Decimal type by default (with the exception of the Count function). In addition StimulReport.Net allows to make calculations using two types of data - Double and Int64. If you want the aggregate function to return the result of calculation using the Double of data write the Latin D in upper register before the function name. If you want to make calculations using the Int64 type you should write the Latin I in upper register before the function name. For example, for calculation of a sum using the Int64 type you should write: SumI Š 2003-2008 Stimulsoft
152
User Manual
For the Double type: SumD
For the Decimal type: Sum
Such separation allows to avoid sacrifice of accuracy when aggregate function calculations. The return type of an aggregate function result. Aggregate function spelling
Type of return value
Sum SumD SumI Count
Decimal Double Int64 Int64
Notice. The Count function is always being calculated using the Int64 type. 1.11.5 Expressions with aggregate functions
Expressions with aggregate functions Expressions with aggregate functions are used only in the Text expression, Text component or the SystemText component. To sum up all values of one column you suffice to write in the text expression as follows: {Sum(DataSource.Column)}
Also you may use combine expressions: {100 + Sum(DataSource.Column) * 2}
Important! Do not use synchronously more than one aggregate functions in the text expression. In this case StimulReport.Net cannot make calculations correct. But if, nevertheless, you need to do it we recommend you using events of components for calculation
Š 2003-2008 Stimulsoft
Contents
153
of totals. For example, you want to calculate the number of strings and sum up expression values. For this you should add the Footer band to a report. In this band you must put two Text components In the first component you should specify: {Count()}
- in this component there will be the number of strings output. In the second component you should specify: {Sum(Products.UnitsInStock)}
- in this component there will be the number of values from the UnitsInStock column output. The example of a report using aggregate functions.
As evident from the sample for calculation of number of strings of the Count function there is no need in additional arguments. One argument has been specified to the Sum function. It is the expression that should be summed up. In other words the report generator has specified to which Data band all these aggregate functions belong to and how many times these functions must be called. Rendered report with two totals in the list.
Š 2003-2008 Stimulsoft
154
User Manual
This occurred because text components, in which aggregate functions had been used, were placed on the total Footer band. This band belongs to a Data band. This enables the report generator to bind the aggregate functions and the Data band automatically. There are several types of total bands in StimulReport.Net. They are as follow: · ReportSummaryBand - this band is used for totals output of a report on the whole; · PageFooterBand - this band is used for totals output of a page; · FooterBand - this band is used for totals output of a list; · GroupFooterBand - this band is used for totals output of a group. Placing components and aggregate functions together allows the report generator to indicate to which Data band do these aggregate functions belong. Also, in addition, you can put the component with aggregate function on the Data band. In this case there will be an output of the result of an aggregate function calculation of all strings. Notice. In most cases StimulReport.Net automatically binds the aggregate function and the Data band together. 1.11.6 Totals with conditions
Totals with condition Often you need to calculate totals with condition.. For example, you want to sum up all values higher than zero. StimulReport.Net allows to add a condition to an aggregate function. When you add a condition to an aggregate function you should add If to this aggregate function name and additional argument with condition. For example: {SumIf(Products.UnitsInStock, Products.UnitsInStock > )}
- this expression will return the sum of elements but every element is to be higher than zero. For the Count function: {CountIf(Products.UnitsInStock == 0)}
- this expression will return the sum of elements equal in zero. If you want to make calculations using the Double or the Int64 types then, at first, you should add Latin D or I and then If to the aggregate function name. For example: {SumDIf(Products.UnitsInStock, Products.UnitsInStock > 0)}
© 2003-2008 Stimulsoft
Contents
155
1.11.7 Calculation of totals of a page and of a container
Calculation of totals of a page and of a container It is very simple to calculate totals of a container or a page. You should write in lower case the Latin c before an aggregate function name. For example: {cCount(DataBand1)}
- this expression will return the number of strings of one page. Notice. A page is a container too. Therefore calculation of totals of a page goes on the same way as calculation of totals of a container. When calculation of totals of a container or of a page you should specify the Data band by which the aggregate function will be calculated. This is necessary because more than one Data band can be located on one page. Notice. For calculation of an aggregate function of a container you should write in lower case the Latin c before an aggregate function name. On one page or a container you may use any number of aggregate functions. StimulReport.Net has no limit in it. You can combine totals of a page with a condition. For example: {CountIf(DataBand1, Products.UnitsInStock = 0)}
- this expression will return the number of elements equal in zero on this page. 1.11.8 Calculation of totals of a column
Calculation of totals of a column Using StimulReport.Net you can calculate totals in a column. Just write col in lower case before the aggregate function name. For example: {colCount()}
- this expression will return the number of strings in one column.
Š 2003-2008 Stimulsoft
156
User Manual
There is one restriction in the calculation of totals in a column in StimulReport.Net. Totals can only be calculated in columns on a page. You cannot calculate totals in columns in the Data band. Important! Totals can only be calculated in columns on a page. You cannot calculate totals in columns in the Data band. When calculating totals in a column it is better put both a text component with an aggregate function the ColumnHeader, ColumnFooter, Header or Footer bands. Notice. For aggregate function calculation in a column you should write col in lower case before the aggregate function name. You can calculate unlimited number of totals in a column. There are no any restrictions applied. Also it is acceptable to combine totals in a column with a condition. For example: {colCountIf(DataBand1, Products.UnitsInStock = 0)}
- this expression will return the number of strings with true condition in a column.
Š 2003-2008 Stimulsoft
Contents
157
1.11.9 Calculation of totals in a code of report events
Calculation of totals in a code of report events Using StimulReport.Net you may make calculation of aggregate functions in the code of events of a report. This allows to calculate aggregate functions with complex logic and condition. Another advantage of StimulReport.Net is that when report rendering you call the value to be calculated from the report code and make changes. If you want to make such a calculation the variable which stores the value of an aggregate function is required. For this you should create a new variable in the data dictionary. Important! Usage of variables from the code to store the result of an aggregate function calculation is barred. You should use variables from the data dictionary. The window to create a new variable.
Here you specify the type of a variable, e.g. Decimal, and the initial value equal in zero. Then from the Data band in the Render event you should set the code of a variable increment. For example, if you want to calculate the sum of variables of the Products.ItemsInStock field then the code will be as follows:
C# MyTotals += Products.ItemsInStock;
Š 2003-2008 Stimulsoft
158
User Manual
VB MyTotals = MyTotals + Products.ItemsInStock;
Addition of a code into the event for calculation of totals.
The RenderingEvent event The Data band in which the RenderingEvent event the calculation will be made. The code for calculation of a sum For calling to the variable that contain the value of a total write in the text expression as follows: {MyTotal}
If, after you have written the text expression, you run the report rendering. Then when the report rendering will reach the component which contains the expression with the total variable there will be an output of this variable. Therefore you should specify to the report generator that the component output must be done right after the whole report rendering when the variable will be calculated completely. For this you must set the ProcessAtEnd property of the text component in True. Notice. Expressions of text components which the ProcessAtEnd property is set in True are always being calculated at the end of the report rendering. As was written before the total will be calculated and shown in the proper part of a report. Š 2003-2008 Stimulsoft
Contents
159
Rendered report with output of the total calculated in the code of the report.
1.11.10 Calculation of growing total
Calculation of a growing total A growing total is calculated on the same way as calculation of totals using the code of events. But there is one distinction that for the Text components you do not have to set the ProcessAtEnd property in true. When the report generator is processing the component which outtypes a variable (used for calculation) it will outtype a component immediately. So if the Text component is in the PageFooter band then the total output of a page will be shown and as there is re-initialization then the variable will compile a total. 1.11.11 Invisible bands
Invisible bands Many reports use invisible bands by a certain condition. The report generator will skip turned on Data bands by default. But if you want to take into calculation invisible Data bands you should set the CalcInvisible property of the Data band in True. When you do this only invisible Data bands will be outtyped and, when calculating of aggregate functions, all strings will be calculated. 1.11.12 Totals and automatic change of a size
Totals and automatic change of a size There is one feature that, when you use automatic change of a size, is responsible for the calculation of totals output. As a rule in the moment when the component size specification is in process the result of the aggregate function is still unknown. Therefore, considering the result of the aggregate function, the component cannot adjust its size. This feature should remembered when reports rendering. 1.11.13 Aggregate functions syntax
Aggregate functions syntax See the aggregate functions syntax in the example of the Sum function: Sum(expression) Sum(band, expression) SumIf(band, expression, condition) Š 2003-2008 Stimulsoft
160
User Manual
expression – expression for calculation; band – a name of a band for calculation; condition – a condition of inclusion of an expression into the calculation. When you calculate an aggregate function on a page or container, you should write a letter “c” first and then the aggregate function name. See the sample: cSum(expression) cSum(band, expression) cSumIf(band, expression, condition) For calculation of totals of a container you should write col first and then the aggregate function name: colSum(expression) colSum(band, expression) colSumIf(band, expression, condition) The Count function has a distinguishing feature from other aggregate functions. It does not have an expression for calculation. Syntax of this function see below. Count() CountIf (condition) Count (band) CountIf(band, condition) cCount () cCount (band) cCountIf(band, condition) colCount () colCount (band) colCountIf(band, condition) Important! If you use the C# programming language all aggregate functions always check the register.
1.11.14 Calculation of totals in hierarchical reports
Calculation of totals in hierarchical reports When building the Master-Detail reports you may meet the problem with calculation of totals in hierarchical reports. What is it? Suppose, you have a list of products which is output by categories. The report is built using Master-Detail relations. In other words we have a certain number of master strings (categories) and a certain number of detail strings (products). © 2003-2008 Stimulsoft
Contents
161
So we need to count how many products are output in the report. If we add the FooterBand with the aggregate function to the Detail band, then we will get the total by each group.
Š 2003-2008 Stimulsoft
162
User Manual
If we add the FooterBand to the MasterBand then we will get the number of categories. In this cases it is possible to use the calculation of totals. For this purpose you need to specify names of both DataBands in the aggregate function. In our example: Count(MasterBand: DetailBand).
Š 2003-2008 Stimulsoft
Contents
163
The result of the Count(MasterBand:DetailBand) function is the number of products by all categories.
1.12
Navigation
Navigation Introduction 164 Bookmarks 164 Tree of bookmarks 166 Hyperlinks 169 Reports with content 170 Bookmarks creation using a code 173 Š 2003-2008 Stimulsoft
164
User Manual
1.12.1 Introduction
Introduction StimulReport.Net has all necessary tools for creation of hyperlinks both in a report and from a report to objects outside the report. Base tools are bookmarks and hyperlinks and bookmarks tree in the window of preview. The Bookmark property is used for making bookmarks. The Hyperlink property is used for hyperlinks specifying. All components (visible - text, image, page etc; invisible - bands, containers) have both of these properties. Thus between all components of a report you can hyperlinks and on any components bookmarks can be made. Notice. Controls which are being used for dialog boxes building do not have specified properties and cannot form bookmarks and elements of navigation. 1.12.2 Bookmarks
Bookmarks Bookmarks are used for showing the structure of a report. Also bookmarks are used to mark the component so as to make a reference on it using hyperlinks. All components have the Bookmark property. The expression specified in this property is set in the BookmarkValue property. Setting occurs when the report building. This property is invisible in Properties panel but you can call it from the report code or refer to it from the expression. Before showing report in a window of preview StimulReport.Net views all components of a finished report and logs a tree of bookmarks. Window of report preview, navigation of data.
Š 2003-2008 Stimulsoft
Contents
Bookmark tree in the window of preview Here you can open or hide the bookmark tree Bookmarks samples: Test
MyCompany
You can set expressions in a property. See the following sample: {Line}
Š 2003-2008 Stimulsoft
165
166
User Manual
{Products.ProductName}
Report samples Demo, report: Simple Group 1.12.3 Tree of bookmarks
Tree of bookmarks The tree of allows to see the structure of a report. For example, two bookmarks were specified - on the Master band and on the Detail band. In this case each element of the Master band bookmark fits to a node of a bookmarks tree. All elements of bookmarks from the Detail bands will be added to the proper node of the Master band. The tree of bookmarks in the window of preview.
Š 2003-2008 Stimulsoft
Contents
167
The Master band node A node of the bookmark tree formed according to values of the Bookmark Master band properties. The Detail band node A node of the bookmark tree formed according to values of the Bookmark Detail band properties. If to add the SubDetail band then its elements will be added to the proper node of the Detail band. Notice. The main node in the tree of bookmarks is the node that shows the report on the whole. The tree node name is taken from the ReportAlias property of the report. Therefore if you want to change the node name you should change the ReportAlias property. If an end user hits a tree node in the tree of bookmarks then the report generator will Š 2003-2008 Stimulsoft
168
User Manual
automatically show the component to what this node belongs. At that the component will be selected with red. Important! All bookmarks must have unique names within the limits of one nesting level. Components navigation on a page using the tree of bookmarks.
Bookmark tree The bookmark tree formed on the basis of the values of the BookmarkValue properties of each component. The BookmarkValue property value is the result of calculation of an expression from the Bookmark property. Components Component which were used in making the tree of bookmarks. Selected component After hitting the node in the tree of bookmarks the report generator will show the proper component. The component will be selected with red. Notice. If the bookmark is set on the component (for example - band) that is not shown in the window of preview then it will be highlighted with red anyway. Report templates Demo, report: Anchors
Š 2003-2008 Stimulsoft
Contents
169
1.12.4 Hyperlinks
Hyperlinks Hyperlinks are used in report navigation. Also you can use the Bookmark and Tag properties for this. Hyperlink is set in Hyperlink property. When report rendering the expression specified in this property is set in the HyperlinkValue property. Setting occurs when report building. There are three ways of specifying hyperlinks. You may use one of them.
Hyperlink to another component in the report using a bookmark In this way you should put the # symbol before the hyperlink text. This makes the report generator to understand that this is a reference of a document inside. If in the window of preview you click on this component then the report generator will start to search all bookmarks of this report. If the bookmark name concurs with the hyperlink name (the # symbol is skipped) then this component will be displayed. You should remember that a bookmark is shown in the tree of bookmarks. Notice. The Bookmark property contains the text marker by which, while hyperlink processing, this component will be found.
Hyperlink to another component in the report using Tag In this way you should add two # symbols before a hyperlink. In this case the search is in process using Tag properties of components (two # symbols in the text of a hyperlink are skipped). Tag properties are not shown in the structure of a report. If you want to make navigation without bookmarks showing in structure of a report then you should use this way. Notice. When using Tag properties, you should not use reference to another component in a report in Asp.Net.
Hyperlink to outside documents In this way you should not add any symbols before a hyperlink. The string of a hyperlink is transferred to OS for processing. For example, for Notepad start just write the following: notepad.exe
For jumping to the address in Internet: http://www.site.com
For email hyperlink: mailto: mail@domain.com
Š 2003-2008 Stimulsoft
170
User Manual
Notice. When you build Web reports bookmarks can be used only for visible fields. For example, a text, an image. Otherwise the hyperlink will be ignored. This principle is to be considered when you export reports to other formats. Sample reports. Demo, report: Bookmarks. Hyperlinks 1.12.5 Reports with content
Reports with content Often you need to create a report with contents. In this case you should create the report structure first and then create the report on the whole. But there is a question. How to create page numbering for, at this moment, when content building, numbers of pages, which elements of content refer to, are unknown. For making this decision use the anchor. The AddAnchor method is used for an anchor creation. When you create an anchor the report generator saves the current page and compares it with the specified anchor. For example: AddAnchor(“MyAnchorName”)
- in this line of the code a new anchor with “MyAnchorName” will be created. If you want to get the anchor value you should use the GetAnchorPageNumber method. This method returns the number of a page according to the anchor name. If there is no anchor with such a name the 0 is returned. For example: {GetAnchorPageNumber(“MyAnchorName”)}
- this text expression will return the number of a page according to “MyAnchorName”. So when you have an anchor name you will know the number of a page on which this anchor was created. Using these two methods a content building generates. The content is built first. Instead of numbers of pages hyperlinks to anchors are pasted. At that for all components which call a function for getting a page number via anchor you should set the ProcessAtEnd property in True. It is necessary because these components are to be processed in the end of report rendering when all numbers of pages are known. After the content has been built the whole report building is in process. Anchor are created while report building. After the report has been rendered, instead of hyperlinks, the real page numbers are put on anchors in the content. Let see the anchor usage in a template. Let build the Master-Detail-Detail report which shows the list of products split with categories. For building of such a report you should have two pages - the first for content and the second for a report. On the page of the content we create two bands. Between them we create the MasterDetail link. Then on the Detail band we put the text component. This text component's © 2003-2008 Stimulsoft
Contents
171
ProcessAtEnd property is to be set in True. Notice. You should turn on the ProcessAtEnd property of the text component, which expression returns the number of a page. This property is used for the values of these text components which are to be processed after report rendering (when numbers of pages are known). In the Text property you should specify the following: {GetAnchorPageNumber(component.TagValue)}
- using anchor this text expression will return the number of a page. This template shows how to use anchors in reports.
As an anchor name the value of the Tag property is used. For filling the Tag property the following expression is used: {Products.ProductName}
- here a name of a product is used. Therefore you cannot use the following expression:
{GetAnchorPageNumber(Products.ProductName)}
The component which contains an expression will be processed in the end of report building. So the value of the Products.ProductName field will be equal for all strings – the last in a list. That is why it is necessary to remember the value of the Products.ProductName field for every string when the content is being built. For this use the Tag property. On the second page Š 2003-2008 Stimulsoft
172
User Manual
the report is built. In the Rendering property of the DataBand component (used for the content building) the AddAnchor method is called. This method will return the current page in the moment of its calling. Addition of the code for a new anchor creation to the code of the Rendering event of the Data band.
The anchor name is the value of the Products.ProductName field. As a result the page number is rendered first. Then the page number two and numbers of pages are saved. After report rendering the report generator engine returns to the first page and numbers of pages. Rendered report with the content.
Š 2003-2008 Stimulsoft
Contents
173
Report templates Demo, report: Anchors 1.12.6 Bookmarks creation using a code
Bookmarks creation using a code Using the Bookmark property you can create rather complicated structure of bookmarks in a report. But sometimes you need more properties for your work. For example, you want to add nodes in a tree of bookmarks without the Bookmark. Or else you want to add a node on another nesting level. StimulReport.Net offers you the ManualBookmark property. This invisible property of a report is available only from the report code. It is very simple to use this property. For example, if you want to add a bookmark of the fist nesting level you may use the following code: ManualBookmark.Add("My Bookmark");
This code will create such a bookmark in the tree of bookmarks: A bookmark created from the code.
Š 2003-2008 Stimulsoft
174
User Manual
For example, if you want to add a bookmark of the second nesting level you may use the following code: ManualBookmark["My Bookmark"].Add("Bookmark Level2");
Two bookmarks of different nesting levels created from the code.
The same can be said about the third nesting level creation: ManualBookmark["My Bookmark"]["Level2"].Add("Bookmark Level3");
Three bookmarks of different nesting levels created from the code.
If you want to create three bookmarks at once you should use the last example of this chapter. StimulReport.Net will automatically check whether all bookmarks are in the tree and will add all missed ones. Notice. When you use the Manual Build property you cannot use the Bookmark property to add bookmarks into the tree of bookmarks. Using bookmarks you may need to make navigation. If you want the report generator could find all components you should use the Bookmark property of these components. At that the Bookmark property value should concur with the name of a new bookmark. For example, you want to add a bookmark. Do it as follows: ManualBookmark.Add(Customers.CompanyName);
In accordance with it the Bookmark property of the component you should write as follows: {Customers.CompanyName}
Š 2003-2008 Stimulsoft
Contents
175
As a result all components will be marked as bookmarks with a company name. In the tree of bookmarks these names of companies will be added. And when you select nodes of the tree of bookmarks all components will be found.
1.13
Developer FAQ
Frequently Asked Questions General 175 Report Designer 180 Work with a report 183 Work with cĐžmpiled report 211 Preview 215 Printing Reports 227 Export of reports 233 Configuration 237 1.13.1 General
General How to save load a report 175 How to render a report 176 How to bind data to a report 177 When should I attach data - before loading of a report or after it 177 How to run a report designer 177 How to save load a rendered report 179 How to load DataSet XSD schema 179 How to change the current script language of a report 180 1.13.1.1 How to save load a report
How to save/load a report? To save a report: Š 2003-2008 Stimulsoft
176
User Manual
C# StiReport report = new StiReport(); report.Save("report.mrt");
VB Dim Report As StiReport = New StiReport() Report.Save("report.mrt")
To load a report:
C# StiReport report = new StiReport(); report.Load("report.mrt");
VB Dim Report As StiReport = New StiReport() Report.Load("report.mrt") 1.13.1.2 How to render a report
How to render a report? To render a report and to show a rendered report in the Window of Preview see the following code:
C# StiReport report = new StiReport(); report.Load("report.mrt"); report.Show();
VB Dim Report As StiReport = New StiReport() Report.Load("report.mrt") Report.Show()
Š 2003-2008 Stimulsoft
Contents
177
1.13.1.3 How to bind data to a report
How to bind data to a report? It is necessary to register data in the DataStore to bind them to a report. You can do it this way:
C# DataSet dataSet1 = new DataSet(); ddataSet1.ReadXmlSchema("Demo.xsd"); dataSet1.ReadXml("Demo.xml"); StiReport report = new StiReport(); report.RegData("MyDataSet",dataSet1);
VB Dim Data As DataSet = New DataSet() Data.ReadXmlSchema("Demo.xsd") Data.ReadXml("Demo.xml") Dim Report As StiReport New StiReport() Report.RegData("MyDataSet",Data) 1.13.1.4 When should I attach data - before loading of a report or after it
When should I attach data - before loading of a report or after it? It does not matter. See the example: Example 1: C# StiReport report = new StiReport(); report.Load("MyReport.mrt"); report.RegData("MyDataSet",dataSet1);
VB Dim Report As StiReport = New StiReport() Report.Load("MyReport.mrt") Report.RegData("MyDataSet",DataSet1)
Š 2003-2008 Stimulsoft
178
User Manual
Example 2: C# StiReport report = new StiReport(); report.RegData("MyDataSet",dataSet1); report.Load("MyReport.mrt");
VB Dim Report As StiReport = New StiReport() Report.RegData("MyDataSet",DataSet1) Report.Load("MyReport.mrt")
Both examples are equivalent. 1.13.1.5 How to run a report designer
How to run a report designer? See the following code how to do it:
C# StiReport report = new StiReport(); report.Design();
VB Dim Report As StiReport = New StiReport() Report.Design()
or like this:
C# Stimulsoft.Report.Design.StiDesigner designer = new Stimulsoft.Report.StiDesigner(); designer.Show();
VB Dim Designer As Stimulsoft.Report.Design.StiDesigner = New Š 2003-2008 Stimulsoft
Contents
Stimulsoft.Report.Designer.StiDesigner() Designer.Show() 1.13.1.6 How to save load a rendered report
How to save / load a rendered report? To save a rendered report:
C# //Render a report StiReport report = new StiReport(); report.Load("report.mrt"); report.Render(); //Save a report report.SaveDocument("document.mdc"));
VB 'Render a report Dim Report As StiReport = New StiReport() Report.Load("report.mrt") Report.Render() 'Save a report Report.SaveDocument("document.mdc"))
To load previously saved rendered report:
C# StiReport report = new StiReport(); report.LoadDocument("document.mdc");
VB Dim Report As StiReport = New StiReport() Report.LoadDocument("document.mdc") 1.13.1.7 How to load DataSet XSD schema
How to load DataSet XSD schema? To load DataSet XSD schema you may use the ImportXMLSchema method:
C# Š 2003-2008 Stimulsoft
179
180
User Manual
StiReport report = new StiReport(); DataSet dataSet = new DataSet("Test"); dataSet.ReadXmlSchema("dataset.xsd"); report.Dictionary.ImportXMLSchema(dataSet);
VB Dim Report As StiReport = New StiReport() Dim Data As DataSet = New DataSet("Test") Data.ReadXmlSchema("dataset.xsd") Report.Dictionary.ImportXMLSchema(Data)
DataSet XSD schema is needed only for the Designer. 1.13.1.8 How to change the current script language of a report
How to change the current script language of a report? Use the Language property of the StiReport class to change the current script language of a report. For example:
C# //Change the current language to VB StiReport report = new StiReport(); report.ScriptLanguage = StiReportLanguageType.VB; //Generate a new report report.ScriptNew();
VB 'Change the current language to VB Dim Report As StiReport = New StiReport() Report.ScriptLanguage = StiReportLanguageType.VB 'Generate a new report Report.ScriptNew()
1.13.2 Report Designer
Report Designer Our users find the Designer too complicated. What can we do to cut off unwanted functions 181 What can I do to hide tips when running the Designer 181
Š 2003-2008 Stimulsoft
Contents
181
How to hide the tab page with the report code 181 How to make the Designer not to ask about saving a report before quitting 182 What can I do something after running the Designer but before initialization 182 How to intercept saving/loading a report in the report Designer 182 How to hide something in the data dictionary 182 How to change the name of the edited file in the report Designer 183 How to hide a menu element in the designer 183 1.13.2.1 Our users find the Designer too complicated. What can we do to cut off unwanted functions
Our users find the Designer too complicated. What can we do to disable unwanted functions? Most of designer elements are set in configuration. Therefore, you can disable services which you do not use or which are complicated for users. For also you can check static options located at the StiOptions.Designer. 1.13.2.2 What can I do to hide tips when running the Designer
What can I do to hide tips when running the Designer? Do the following: StiOptions.Designer.ShowTipsOnStartup = false;
1.13.2.3 How to hide the tab page with the report code
How to hide the tab page with the report code? Set the value of the following property in false and the bookmark with the report code will be hidden. StiOptions.Designer.CodeTabVisible = false;
Š 2003-2008 Stimulsoft
182
User Manual
1.13.2.4 How to make the Designer not to ask about saving a report before quitting
How to make the Designer do not ask about saving a report before quitting? Do as follows: StiOptions.Designer.DontAskSaveReport = true;
1.13.2.5 What can I do something after running the Designer but before initialization
What can I do to make something after running the Designer but before initialization? Use the StiDesigner.LoadingDesigner static event. 1.13.2.6 How to intercept saving/loading a report in the report Designer
How to intercept saving/loading a report in the report Designer? You should use two static properties: StiDesigner.SavingReport StiDesigner.LoadingReport 1.13.2.7 How to hide something in the data dictionary
How to hide something in the data dictionary? Use the special Restrictions class. For example:
C# StiReport report = new StiReport(); report.Dictionary.Restrictions.Add("Customers", StiDataType.DataSource, StiRestrictionTypes.DenyShow); report.Dictionary.Restrictions.Add("DataSource._ID", StiDataType.DataColumn, StiRestrictionTypes.DenyShow);
VB
Š 2003-2008 Stimulsoft
Contents
183
Dim Report As StiReport = New StiReport() Report.Dictionary.Restrictions.Add("Customers", StiDataType.DataSource, StiRestrictionTypes.DenyShow) Report.Dictionary.Restrictions.Add("DataSource._ID", StiDataType.DataColumn, StiRestrictionTypes.DenyShow) 1.13.2.8 How to change the name of the edited file in the report Designer
How to change the name of the edited file in the report Designer? Use the ReportFile property of the report. It is recommended if you save the report to the file you cannot use inadmissible characters in the file name. If you process saving or loading reports you may use any characters. 1.13.2.9 How to hide a menu element in the designer
How to hide a menu element in the designer? Use the following code to hide Help Menu:
C# StiConfig.Load(); StiMainMenuService service = StiConfig.Services.GetService(typeof(StiMainMenuService)) as StiMainMenuService; service.ShowHelp = false;
VB StiConfig.Load() Dim Service As StiMainMenuService = TryCast(StiConfig.Services.GetService( GetType (StiMainMenuService)), StiMainMenuService) Service.ShowHelp = False
Place this code at start of your program. Also you can check the DesignerManagement sample project. 1.13.3 Work with a report
Work with a report Access to data 184
Š 2003-2008 Stimulsoft
184
User Manual
Formatting and convertation 190 Variables 192 Miscellaneous 194 1.13.3.1 Access to data
Access to data How to change data of connection with database 184 How to address to the column with data directly without typical conversion 185 How to change a text of query when report rendering 185 All data are received by a report. Is it possible to register in a report 186 How to add a parameter to SQL query 185 How to render a report on the server and send to your client 187 Is it possible to design the report in the designer using a local database and change the database in code once online 187 Is it possible to display images, both stored in a database or hosted on a server 188 Can I change the report connection string on run time 188 How to send parameters for SQL query by application 189 How to check null values 190 How to render Master-Detail reports if two tables are located on another DataSet 190 1.13.3.1.1 How to change data of connection with database
How to change data of connection with database? Before report rendering you can write the following code:
C# //Clear the list of databases report.Dictionary.Databases.Clear(); //Add the database and specify its name and the connection string report.Dictionary.Databases.Add(new StiSqlDatabase("Test", "MyDataConnectionString"));
VB
Š 2003-2008 Stimulsoft
Contents
185
'Clear the list of databases Report.Dictionary.Databases.Clear() 'Add the database and specify its name and the connection string Report.Dictionary.Databases.Add(new StiSqlDatabase("Test", "MyDataConnectionString"))
1.13.3.1.2 How to address to the column with data directly without typical conversion
How to address to the column with data directly without typical conversion? You may use the indexer of the data source. For example:
C# object data = Customers["Phone"];
VB Dim Data As Object = Customers("Phone")
1.13.3.1.3 How to change a text of query when report rendering
How to change a text of query when report rendering? You can use parameters. By default report engine does not support parameters as standard view point. For example: select * from customers where code=:code
In this case you can't detect code. But you can use expression to form any part in SQL query. For example: select * from customers where code = {myvariable} select * from customers where {myvariable} select * from customers {myvariable} select * from {myvariable} where code=1 select {myvariable} from customers where code = {myvariable}
Š 2003-2008 Stimulsoft
186
User Manual
{myvariable} select * from customers where code = {MyStaticClass.GetCondition()} select * from customers where {Datasource.Condition} select {myvar+myvar2} from customers
1.13.3.1.4 All data are received by a report. Is it possible to register in a report
All data are received by a report. Is it possible to register in a report? If all data are received in a report, for example, if you use SQL queries, then there is no need to use the RegData method of a report. 1.13.3.1.5 How to add a parameter to SQL query
How to add a parameter to SQL query? In data source you should create a parameter, In SQL query you write: select * from customers where customerid=@customerid
Then you need to initialize this parameter. For example, for initialization from the code you may use the following code:
C# StiReport report = new StiReport(); report.RegData(myDataset); report.Compile(); report.DataSource["myvariable"].Parameters["@customerid"].ParameterValue = 1;
VB Dim Report As StiReport = New StiReport() Report.RegData(MyDataSet) Report.DataSource["myvariable"].Parameters["@customerid"].ParameterValue = 1
Š 2003-2008 Stimulsoft
Contents
187
1.13.3.1.6 How to render a report on the server and send to your client
How to render a report on the server and send IT to your client? First, generate a report on the server and save rendered report to the stream:
C# StiReport report = new StiReport(); report.RegData(dataSet); report.Render(false); report.SaveDocument(stream);
VB Dim Stream As New MemoryStream Dim Report As New StiReport Report.RegData(DataSet) Report.Render(False) Report.SaveDocument(Stream)
Load a rendered report on a client from the stream and set the following data:
C# StiReport report = new StiReport(); report.LoadDocument(stream); report.Show();
VB Dim Report As New StiReport Report.LoadDocument(stream) Report.Show()
1.13.3.1.7 Is it possible to design the report in the designer using a local database and change the database in code once online
Is it possible to design a report in the designer using the local database and change the database in a code once online? Use the following code:
Š 2003-2008 Stimulsoft
188
User Manual
report.Databases.Clear(); report.Databases.Add(new StiSqlDatabase("MyDatabaseName", "connection string");
The name of a new database must comply with the name of the database in a report. 1.13.3.1.8 Is it possible to display images, both stored in a database or hosted on a server
Is it possible to display images, both stored in a database or hosted on a server? You can use many ways. With properties: 1. Property Image.DataColumn - to load image from database. 2. Property Image.File - to load image from file. 3. Property Image.ImageURL - to direct specify image url. From the code of events: 1. Load an image from the file Image1.Image = Image.FromFile("Image1.gif");
2. Load an image from url Image1.Image = Stimulsoft.Base.Drawing.StiImageFromURL.LoadBitmap( "http://www.domain.com/bitmap.gif");
1.13.3.1.9 Can I change the report connection string on run time
Can I change the report connection string AT run time? You can use the following code: C# StiReport report = new StiReport(); report.Load("MyReport.mrt"); report.Dictionary.Databases.Clear(); report.Dictionary.Databases.Add(new StiSqlDatabase("MyDatabase", "new connection string" Š 2003-2008 Stimulsoft
Contents
189
));
VB Dim Report As New StiReport Report.Load("MyReport.mrt") Report.Dictionary.Databases.Clear() Report.Dictionary.Databases.Add(New StiSqlDatabase("MyDatabase", "new connection string"))
1.13.3.1.10 How to send parameters for SQL query by application
How to send parameters for SQL query by application? 1. You can use expression to form any part in SQL query. First you add variables to SQL query: select * from customers where code = {myvariable}
2. You need to create variable in Report Dictionary 3. You need to initialize variable before report running:
C# StiReport report = new StiReport(); rreport.Load("Variables.mrt"); report.Compile(); //Set Variable report["myvariable"] = 123; report.Render();
VB Dim Report As StiReport = New StiReport() Report.Load("Variables.mrt") Report.Compile() 'Set Variable Report("myvariable") = " Value " Report.Render()
Š 2003-2008 Stimulsoft
190
User Manual
1.13.3.1.11 How to check null values
How to check null values? You can use the following code in the GetValueEvent:
C# if (Customers["Flag"] == null)e.Value = "YES"; else e.Value = "NO";
VB If (Customers("Flag") Is Nothing) Then e.Value = "YES" Else e.Value = "NO" End If
For also you can use function IIF:
C# {IIF(Customers["Flag"] == null, "YES", "NO")}
VB {IIF(Customers("Flag") Is Nothing, "YES", "NO")}
1.13.3.1.12 How to render Master-Detail reports if two tables are located on another DataSet
How to render Master-Detail reports if two tables are located on another DataSet? In this case you should enable caching of all data in one DataSet. For this you should set the CacheAllData property in True. You can do this from the report dictionary 1.13.3.2 Formatting and converting
Formatting and converting How to convert coordinates of one unit into another 191
Š 2003-2008 Stimulsoft
Contents
191
How to convert coordinates and sizes of a report 191 How to output the value instead of DBNull and Null values 192 1.13.3.2.1 How to convert coordinates of one unit into another
How to convert coordinates of one unit into another one? Use the ConvertFromHInches and ConvertToHInches methods of the StiUnit class to convert coordinates. For example:
C# //Converts a value from centimeters to inches StiUnit unitFrom = new StiCentimetersUnit(); StiUnit unitTo = new StiInchesUnit(); double value = 2.54; value = unitFrom.ConvertToHInches(value); value = unitFrom.ConvertFromHInches(value);
VB 'Converts a value from centimeters to inches Dim UnitFrom As StiUnit = New StiCentimetersUnit() Dim UnitTo As StiUnit = New StiInchesUnit() Dim Value As Double = 2.54 Value = UnitFrom.ConvertToHInches(value) Value = UnitFrom.ConvertFromHInches(value)
1.13.3.2.2 How to convert coordinates and sizes of a report
How to convert coordinates and sizes of a report? All classes which realizes the IStiUnitConvert interface may convert coordinates and sizes of a report from one unit into another. The Convert method can be used for conversion. For example:
C# //Converts coordinates and sizes of a report from the current unit into inches StiReport report = new StiReport(); StiUnit unitTo = new StiInchesUnit(); report.Convert(report.Unit, unitTo);
Š 2003-2008 Stimulsoft
192
User Manual
VB 'Converts coordinates and sizes of a report from the current unit into inches Dim Report As StiReport = New StiReport() Dim UnitTo As StiUnit = New StiInchesUnit() Report.Convert(Report.Unit, UnitTo)
1.13.3.2.3 How to output the value instead of DBNull and Null values
How to output the value instead of DBNull and Null values? You should use text values formatting - the TextFormat property. Also you may disable forced conversion of null values - the report.ConvertNulls property. 1.13.3.3 Variables
Variables How to add a variable in a report 192 How to get access to the value of a variable 193 How to add system variable to the text 193 1.13.3.3.1 How to add a variable in a report
How to add a variable in a report? You can use the following code to add a variable to a report in the code: Adds a new MyVariable variable of the int type:
C# report.Dictionary.Variables.Add(new StiVariable("Category", "MyVariable", typeof(int), "1", false));
VB Report.Dictionary.Variables.Add(New StiVariable("Category", "MyVariable", CType(GetType(int), Type), "1", False))
Š 2003-2008 Stimulsoft
Contents
193
Adds a new MyVariable variable of the string type:
C# report.Dictionary.Variables.Add(new StiVariable("Category", "MyVariable", typeof(string), "1", false));
VB Report.Dictionary.Variables.Add(New StiVariable("Category", "MyVariable", CType(GetType(String), Type), """1""", False))
1.13.3.3.2 How to get access to the value of a variable
How to get access to the value of a variable? To access to the value of variable, you may use this code:
C# StiReport report = new StiReport(); report.Load("Variables.mrt"); report.Compile(); //Set Variable report["VariableName"] = "Value"; //Get Variable object value = report["VariableName"];
VB Dim Report As StiReport = New StiReport() Report.Load("Variables.mrt") Report.Compile() 'Set Variable Report("VariableName") = " Value " 'Get Variable Dim Value As Object = Report("VariableName")
1.13.3.3.3 How to add system variable to the text
How to add system variable to the text? Š 2003-2008 Stimulsoft
194
User Manual
Simple use the following code:
text1.Text = "{PageNofM}";
1.13.3.4 Miscellaneous
Miscellaneous How to change sorting of data 195 How to get actual size of a component 195 How to find a component by its name 195 How to get or set a text to rtf component in rtf format 196 How should I add a bookmark for a component using code 196 What is the difference between the Text and the TextValue 196 What should I specify in the DataColumn field of an image 196 How to load image from the path, stored in database 197 How to bind ComboBox on Form to Data 197 How to get access to the text of the report code 198 How to generate a new code of a report 198 How to update a report code 198 How to use custom assemblies in a report 199 How should I get access to objects of my application from a report 199 How to work with columns which names concur with the csharp key word 201 How to load an image from URL 201 How to find the name of the file from which the report was loaded 202 How to change CheckBox value on a page in preview 202 How to change the page number 203 Are there any ways to print a header for a databand on the second page 203 How to minimize the font size of the text component depending on the text size 204 How to change duplicated values on a band with one 204
Š 2003-2008 Stimulsoft
Contents
195
How to add the event handler to events 205 How to get access to pages of a report 206 How to get the total of a band without its printing 206 How to sort data on the base of the Expression 206 Cross-report rendering by 3 tables 208 Text formatting in the RichText component in the GetValue event handler 208
1.13.3.4.1 How to change sorting of data
How to change sorting of data? To change sorting see below: DataBand1.Sort = new string[2] { "ASC", "Name" };
1.13.3.4.2 How to get actual size of a component
How to get actual size of a component? Use the StiComponent.GetActualSize method. This method returns actual size of the component. You should remember that if you want the method to return correct data of the CanGrow property, the CanShrink and AutoWidth (for text) properties must be in true. 1.13.3.4.3 How to find a component by its name
How to find a component by its name? To find component by its name use this code:
C# StiComponent component = report.GetComponentByName("ComponentName");
VB Dim Component As StiComponent = Report.GetComponentByName("ComponentName"); Š 2003-2008 Stimulsoft
196
User Manual
1.13.3.4.4 How to get or set a text to rtf component in rtf format
How to get or set a text to rtf component in rtf format? Use the StiRichText.RtfText property. 1.13.3.4.5 How should I add a bookmark for a component using code
How should I add a bookmark for a component using code? Use the following code: component.Bookmark = "{Categories.CategoryName}";
1.13.3.4.6 What is the difference between the Text and the TextValue
What is the difference between the Text and the TextValue? In the Text property the text expression, which will be calculated while rendering, is stored. After it will be calculated the result will be put in to the TextValue. In other words you can specify expressions. For example: text1.Text = "Phone: {Customers.Phone}";
In the TextValue you can specify only strings: text1.TextValue = "123";
If the Text and TextValue are specified together then for output the TextValue is used. 1.13.3.4.7 What should I specify in the DataColumn field of an image
What should I specify in the DataColumn field of an Š 2003-2008 Stimulsoft
Contents
197
image? The data source and, after the point, the column with data are specified in this field. For example: Customers.Photo
Brackets should not be put. Also you may use call through the link. For example: Products.Customers.Photo
1.13.3.4.8 How to load image from the path, stored in database
How to load image from the path, stored in database? For this you should use the BeforePrintEvent event. Specify the following code in the event:
C# Image1.Image = Image.FromFile(MyDataSource.ImagePath);
VB Image1.Image = Image.FromFile(MyDataSource.ImagePath)
For also you can use ImageData property:
C# {Image.FromFile(MyDataSource.ImagePath)}
VB {Image.FromFile(MyDataSource.ImagePath)}
1.13.3.4.9 How to bind ComboBox on Form to Data
How to bind ComboBox on Form to Data? Š 2003-2008 Stimulsoft
198
User Manual
1. You may specify the DataBindings property. 2. You may get native ComboBox by this code: ComboBox comboBox = ReportComboBox.Control;
3. You may fill combo box in the FormLoad events:
ReportComboBox.Items.Add("123");
1.13.3.4.10 How to get access to the text of the report code
How to get access to the text of the report code? Use the Script property of the StiReport class. This property contains a text of the report code. 1.13.3.4.11 How to generate a new code of a report
How to generate a new code of a report? Use the ScriptNew method of the StiReport class to generate a new code of a report. For example:
C# StiReport report = new StiReport(); report.ScriptNew();
VB Dim Report As StiReport = New StiReport() Report.ScriptNew()
1.13.3.4.12 How to update a report code
How to update a report code? To update a report code you should use the ScriptUpdate method of the StiReport class. For example:
Š 2003-2008 Stimulsoft
Contents
199
C# StiReport report = new StiReport(); report.ScriptUpdate();
VB Dim Report As StiReport = New StiReport() Report.ScriptUpdate()
You should remember that, before report compilation, the report code is automatically updated. Therefore, there is no need to call the ScriptUpdate method.
1.13.3.4.13 How to use custom assemblies in a report
How to use custom assemblies in a report? Make sure the window of properties is visible and selected (press F4 once or twice or select in menu “View” -> “Properties”). In the window of properties select top item in combo box (for example “MyReport: Report”), there will be “Referenced Assemblies“ property, click […] button to edit its value. Add your assemblies and click [OK] button. Now you could use functions from custom assemblies in reports code – in report objects events handlers and etc. 1.13.3.4.14 How should I get access to objects of my application from a report
How should I get access to objects of my application from a report? If you want to get access to objects of your application from a report you should do the following steps: 1. You have to add a reference to assembly of your application. References are added in the ReferencedAssemblies property of a report.
© 2003-2008 Stimulsoft
200
User Manual
2. Then describe a field which contains data in a class of a report
If you want to describe the field without complete path of this field then, in addition, you should add the namespace of your type.
3. It is necessary to initialize the described field before report rendering.
C# Š 2003-2008 Stimulsoft
Contents
201
StiReport report = new StiReport(); report.Load("report.xml"); //Compile the report first report.Compile(); //Initialize the field in a report report.CompiledReport["Parameters"] = OurParameters; report.Render();
VB Dim Report As StiReport = New StiReport() Report.Load("report.xml") 'Compile the report first Report.Compile() 'Initialize the field in a report Report.CompiledReport("Parameters") = OurParameters Report.Render()
After all actions are done you can access to the field of your application from the script. See the sample: {Parameters.SomeParameter}
1.13.3.4.15 How to work with columns which names concur with the csharp key word
How to work with columns which names coincide with the C# key word? Add the @ symbol before the column name. For example - @class 1.13.3.4.16 How to load an image from URL
How to load an image from URL? Use the following code for loading an image in the Bitmap format:
Image1.Image = Stimulsoft.Base.Drawing.StiImageFromURL.LoadBitmap("http:// www.domain.com/bitmap.gif"); Š 2003-2008 Stimulsoft
202
User Manual
Use the following code for loading an image in the Metafile format:
Image1.Image = Stimulsoft.Base.Drawing.StiImageFromURL.LoadMetafile( "http://www.domain.com/bitmap.emf");
For also you can use property ImageURL of image component. 1.13.3.4.17 How to find the name of the file from which the report was loaded
How to find the name of the file from which the report was loaded? You can get previous file path from property ReportFile. Sample:
string path = report.ReportFile;
1.13.3.4.18 How to change CheckBox value on a page in preview
How to change CheckBox value on a page in preview? I would like to know which function can work like a click button? I try to find some function that I can use while preview report and I can add some X mark in the preview report by click on preview report and that X mark will appear on the report Use CheckStyle = Cross for "X" symbol Please write to the ClickEvent event handler:
C# Stimulsoft.Report.Components.StiCheckBox check = sender as Stimulsoft. Report.Components.StiCheckBox; if (check.CheckedValue == null || ((bool)check.CheckedValue) == false) check.CheckedValue = true; else check.CheckedValue = false; Invalidate();
Š 2003-2008 Stimulsoft
Contents
203
VB Dim box1 As Stimulsoft.Report.Components.StiCheckBox = CType(sender, Stimulsoft.Report.Components.StiCheckBox) If ((box1.CheckedValue Is Nothing) OrElse Not CType(box1.CheckedValue, Boolean)) Then box1.CheckedValue = True Else box1.CheckedValue = False End If MyBase.Invalidate
1.13.3.4.19 How to change the page number
How to change the page number? If you want to change the page number all you need is to assign the value to the system variable of the PageNumber. For example: PageNumber = 1;
For also you can use special property ResetPageNumber. 1.13.3.4.20 Are there any ways to print a header for a databand on the second page
Are there any ways to print a header for a databand on the second page? You can use BeforePrintEvent. See example code:
C# if (PageNumber == 1)HeaderBand1.Enabled = false; else HeaderBand1.Enabled = true;
VB If (MyBase.PageNumber = 1) Then Me.HeaderBand1.Enabled = False Else Me.HeaderBand1.Enabled = True End If
Š 2003-2008 Stimulsoft
204
User Manual
1.13.3.4.21 How to minimize the font size of the text component depending on the text size
How to minimize the font size of the text component depending on the text size? In the GetValue event of the Text component you should set the following code:
C# StiText text = sender as StiText; text.Font = text.GetActualFont(Customers.CompanyName); StiText text = sender as StiText; text.Font = text.GetActualFont(Customers.CompanyName, minimumFontSize);
VB Dim text1 As Components.StiText = TryCast(sender, Components.StiText) text1.Font = text1.GetActualFont(Customers.CompanyName) Dim text1 As Components.StiText = TryCast(sender, Components.StiText) text1.Font = text1.GetActualFont(Customers.CompanyName, minimumFontSize)
where the minimumFontSize - the minimally admissible size for the font. For also you can use two properties of the text component: ShrinkFontToFit ShrinkFontToFitMinimumSize 1.13.3.4.22 How to change duplicated values on a band with one
How to change duplicated values on a band with one?
Š 2003-2008 Stimulsoft
Contents
205
For the ProcessingDuplicates property the following values are: 1. ProcessingDuplicates=Merge - duplicated values are merged 2. ProcessingDuplicates=None - duplicated values are output without changes 3. ProcessingDuplicates=Hide - the first string of duplicated values is output 1.13.3.4.23 How to add the event handler to events
How to add the event handler to events? 1. After you call Show, report engine automatically calls the Compile method and creates a new report - report.CompiledReport. To add event handler use this code:
C# report.Compile(); report.CompiledReport.GetComponents()["ComponentName"].BeforePrint += new EventHandler(Component_BeforePrint); report.Show();
VB Report.Compile() AddHandler Report.CompiledReport.GetComponents.Item("ComponentName"). BeforePrint, New EventHandler(AddressOf Me.Component_BeforePrint) Report.Show()
In this code handler subscribe to event in compiled report
Š 2003-2008 Stimulsoft
206
User Manual
2. You can set event script directly:
C# component.BeforePrintEvent.Script = "MessageBox.Show(\"test\")";
VB Component.BeforePrintEvent.Script = "MessageBox.Show(""test"")"
You can assign script to event and after compilation this script go to a handler. 1.13.3.4.24 How to get access to pages of a report
How to get access to pages of a report? Pages of a report are stored in the Pages collection of reports. See the sample:
C# //Returns the first page of a report StiPage page = report.Pages[0];
VB 'Returns the first page of a report Dim Page As StiPage = Report.Pages(0)
1.13.3.4.25 How to get the total of a band without its printing
How to get the total of a band without its printing? You should decrease the height of the data band to 0. 1.13.3.4.26 How to sort data on the base of the Expression
How to sort data on the base of the Expression? Often you need to sort data on the base of expression. The result of calculation depends on some fields in the data source. For example you have set of numbers represented as a string. If to sort this data source without converting strings to the number format, then the order of numbers in the data source will not be complied with the natural order of this numbers. Š 2003-2008 Stimulsoft
Contents
207
Numbers have different precision and will be sorted as strings: 1000 20 300
If to change the string type of a column to numerical, then sorting will be done correctly. But how to sort without changing the type of the data source? For this purpose you may use the Expression as a condition for sorting. {int.Parse(MyDataSource.MyColumn)}
As it is impossible to specify the expression as a condition for sorting, then you need to use the following trick. Change your sorting to grouping. Specify the expression (see below) for sorting as a condition of grouping. Set the GroupHeaderBand height to 0.
After that, strings will be sorted in correct order. 20 300 1000
Š 2003-2008 Stimulsoft
208
User Manual
Notice. In the expression you can use any rows from the table, used for sorting.
1.13.3.4.27 Cross-report rendering by 3 tables
Cross-report rendering by 3 tables Let see the following task. For example, we need render a report by 3 tables: Categories, Products, Order_Details. We must get the next tables in the report: - by Products strings, by Categories columns. On the row/column intersection of a report a row from the Order_Details is to be output. Order_Details is related to Categories and Products tables using Relations. See below how to do it. Place the DataBand on a page. Products data source. Place the CrossTab with Categories data source on the DataBand. Place the StiText with the field from the Order_Details on the CrossBand. To scroll the Order_Details to the row you need it is necessary to add a handler into the OnBeforePrint of the StiText component which helps you in scrolling . Order_Details.First(); while (!Order_Details.IsEof) { if (Order_Details.OrderID == Categories.CategoryID && Order_Details.OrderID == Products.ProductID) break; Order_Details.Next(); }
Why the Order_Details cannot be automatically scrolled to the row though the relation for the Products and Categories exist? Because data sources are scrolled when they are related to the Databand. It is impossible to scroll as in Delphi because there can be a lot of relations. But better way in this case is - a big SQL-query and a cross table. Or the query is a bit smaller and is placed on the Databand. 1.13.3.4.28 Text formatting in the RichText component in the GetValue event handler
Text formatting in the RichText component in the GetValue event handler Sometimes you need to format the RTF text in the StiRichTextBox object. For the text formatting you can use the GetValue event handler. For this operation you need to create the StiRichText component. See below the example of how to use the GetValue event handler. The StiRichTextBox is used in this example. It has a difference from the standard one. It has more functionality in working with the RTF text.
Š 2003-2008 Stimulsoft
Contents
209
C# // Create auxiliary StiRichTextBox object StiRichTextBox rich = new StiRichTextBox(); // rtf-text unpacking rich.Rtf = StiRichText.UnpackRtf(System.Xml.XmlConvert.DecodeName(e. Value)); //Select rtf range //Select area of a text for using formatting to it rich.SelectionStart = 0; rich.SelectionLength = 9; //Using lowercase to selected text rich.SelectionCharOffset = -5; // Selected text with center alignment rich.SelectionAlignment = StiRtfSelectionAlign.Center; // Set the color of the selected text rich.SelectionColor = Color.Red; // Set the font for selected text rich.SelectionFont = new Font("Arial", 20, FontStyle.Bold); rich.SelectionStart = 9; rich.SelectionLength = 3; rich.SelectionFont = new Font("Arial", 25); rich.SelectionColor = Color.Blue; rich.SelectionStart = 12; rich.SelectionLength = 11; rich.SelectionFont = new Font("Arial", 20, FontStyle.Bold); //Set selected text in uppercase rich.SelectionCharOffset = 10; // Rtf text packing e.Value = System.Xml.XmlConvert.EncodeName(StiRichText.PackRtf(rich.Rtf)); // Release of resources of additional component rich.Dispose();
VB Dim box1 As New StiRichTextBox box1.Rtf = StiRichText.UnpackRtf(System.Xml.XmlConvert.DecodeName(e.Value)) box1.SelectionStart = 0 box1.SelectionLength = 9 box1.SelectionCharOffset = -5 box1.SelectionAlignment = StiRtfSelectionAlign.Center box1.SelectionColor = Color.Red box1.SelectionFont = New Font("Arial", 20, FontStyle.Bold) box1.SelectionStart = 9 box1.SelectionLength = 3
Š 2003-2008 Stimulsoft
210
User Manual
box1.SelectionFont = New Font("Arial", 25) box1.SelectionColor = Color.Blue box1.SelectionStart = 12 box1.SelectionLength = 11 box1.SelectionFont = New Font("Arial", 20, FontStyle.Bold) box1.SelectionCharOffset = 10 e.Value = System.Xml.XmlConvert.EncodeName(StiRichText.PackRtf(box1.Rtf)) box1.Dispose
On the picture you can see the StiRichText component before and after setting the GetValue handler.
Properties of the RichText component Property
Function
SelectionAlignment
Controls the Rtf - text alignment Set the SelectionHangingIndent property to an integer representing the distance in pixels between the left edge of the first line of text in the paragraph and the left edge of subsequent lines in the same paragraph. Integer value. Sets the distance in pixels between the left margin of the control and the left margin of the text. Set the SelectionHangingIndent property to an integer representing the distance in pixels between the left edge of the first line of text in the paragraph and the left edge of subsequent lines in the same paragraph. The value of the SelectionHangingIndent property only applies to lines in a paragraph that have wrapped below the first line. Set the SelectionRightIndent property to an integer representing the distance in pixels between the right edge of the control and the right edge of the text.
SelectionHangingIndent
SelectionIndent
SelectionRightIndent
Š 2003-2008 Stimulsoft
Contents
211
1.13.4 Work with compiled report
Work with cĐžmpiled report How to compile report to assembly 211 How to load a report from assembly into the memory once only 211 How to use the compiled report assembly 212 How to get compatibility of versions of the report generator and compiled reports 213 How to load a report from assembly 214
1.13.4.1 How to compile report to assembly
How to compile report to assembly? Use the Compile method:
C# //Compile to file report.Compile("MyReport.dll"); //Compile to stream report.Compile(stream);
VB 'Compile to file Report.Compile("MyReport.dll") 'Compile to stream Report.Compile(stream)
Besides, you can save a report in assembly from the report designer.
1.13.4.2 How to load a report from assembly into the memory once only
How to load a report from assembly into the memory once Š 2003-2008 Stimulsoft
212
User Manual
only? When you use the StiReport.GetReportFromAssembly method the report is loaded into the memory in every cases. This can be avoided if you will specify the additional parameter when loading a report from assembly:
C# StiReport report = StiReport.GetReportFromAssembly("MyReport.dll", true);
VB Dim Report As StiReport = StiReport.GetReportFromAssembly("MyReport.dll", True)
You should remember that, in this case, the .dll file will be blocked until application is running.
1.13.4.3 How to use the compiled report assembly
How to use the compiled report assembly? In Reports Designer you could save you report as assembly (DLL-file). To use such reports in you application you can use the following code:
C# StiReport report = StiReport.GetReportFromAssembly("MyReport.dll", true);
VB Dim Report As StiReport = StiReport.GetReportFromAssembly("MyReport.dll")
Also you could compile your report on first access and after report is compiled use compiled version of report next times – it will improve performance.
C# string reportName = "MyReport.mrt"; string reportDllName = "MyReport.dll"; StiReport report = null; // if report dll is not exists ... if (!File.Exists(reportDllName)) Š 2003-2008 Stimulsoft
Contents
213
{ // load report definition report = new StiReport(); report.Load(reportName); // compile report, save dll version of report report.Compile(reportDllName); } else // if report assembly is available … { // … use it report = StiReport.GetReportFromAssembly(reportDllName); }
VB Dim ReportName As String = "MyReport.mrt" Dim ReportDllName As String = "MyReport.dll" Dim Report As StiReport = Nothing ' if report dll is not exists ... If Not File.Exists(ReportDllName) Then ' load report definition Report = New StiReport Report.Load(ReportName) ' compile report, save dll version of report Report.Compile(ReportDllName) Else ' if report assembly is available … Report = StiReport.GetReportFromAssembly(ReportName) End If
1.13.4.4 How to get compatibility of versions of the report generator and compiled reports
How to get compatibility of versions of the report generator and compiled reports? Compatibility can be taken by two ways: 1) Write bindingRedirects in config. For example: <?xml version="1.0" encoding="utf-8" ?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Stimulsoft.Report" publicKeyToken=" EBE6666CBA19647A" culture="neutral" /> © 2003-2008 Stimulsoft
214
User Manual
<bindingRedirect oldVersion="1.30.0.0" newVersion="1.31.0.0/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Stimulsoft.Report.Export.HtmlExport" publicKeyToken="EBE6666CBA19647A" culture="neutral" /> <bindingRedirect oldVersion="1.30.0.0" newVersion="1.31.0.0"/> </dependentAssembly>
[... and etc. for each new assembly ...] </assemblyBinding> </runtime> </configuration>
For more detail - search in MSDN by "<runtime>" 2) Create policy publisher files for every old versions. For example: policy.1.23.Stimulsoft.Base.dll policy.1.30.Stimulsoft.Base.dll policy.1.23.Stimulsoft.Report.dll policy.1.30.Stimulsoft.Report.dll etc. Details - search in MSDN by "publisher policy files".
1.13.4.5 How to load a report from assembly
How to load a report from assembly? For this purpose use the GetReportFromAssembly static method of the StiReport class. This method returns the created report. See examples of the method call:
C# //Load report from Assembly StiReport report = StiReport.GetReportFromAssembly(assembly); //Load report from a file StiReport report = StiReport.GetReportFromAssembly("MyReport.dll"); //Load report from a stream StiReport report = StiReport.GetReportFromAssembly(stream);
VB 'Load report from Assembly Dim Report As StiReport = StiReport.GetReportFromAssembly(assembly) 'Load report from a file Dim Report As StiReport = StiReport.GetReportFromAssembly("MyReport.dll") 'Load report from a stream Š 2003-2008 Stimulsoft
Contents
215
Dim Report As StiReport = StiReport.GetReportFromAssembly(stream)
1.13.5 Preview
Preview How to process saving and loading of a rendered report by myself 215 How to process printing in the Window of Preview 216 How to disable buttons in the toolbar 217 How to disable the toolbar 217 How to specify to the report generator to output the result of report rendering in the StiPreviewControl 218 How to specify to the report generator to use my window of report preview 219 How to set zoom of pages in the StiPreviewControl 220 How to set predefined zoom of pages in the StiPreviewControl 220 How to refresh the report preview in the report code 221 How to load a page into the rendered report from the code of the report 221 How to get access to pages of rendered report 222 How to show all components in preview but do not print them 223 How to add or change an image in the rendered report in the report code 223 How to indicate pressing the cancel button in the Window of Preview and do not show the report 225 How to attach your indicator of pages rendering 226 Why the text I have printed does not look similar with the text in Preview 227 1.13.5.1 How to process saving and loading of a rendered report by myself
How to process saving and loading of a rendered report by myself? You may use static SavingDocument and LoadingDocument events of the StiPreviewControl class. The SavingDocument is used for saving the rendered report. LoadingDocument is used for loading the rendered report. To process saving the rendered report see below:
Š 2003-2008 Stimulsoft
216
User Manual
C# private static void OnSavingDocument(object sender, EventArgs e) { StiReport report = sender as StiReport; report.SaveDocument("MyFile.mdc"); } StiPreviewControl.SavingDocument += new EventHandler(OnSavingDocument);
VB Private Shared Sub OnSavingDocument(ByVal sender As Object, ByVal e As EventArgs) Dim Report As StiReport = TryCast(sender, StiReport) Report.SaveDocument("MyFile.mdc") End Sub AddHandler StiPreviewControl.SavingDocument, New EventHandler(AddressOf Form1.OnSavingDocument)
For processing of loading of the rendered report see below:
C# private static void OnLoadingDocument(object sender, EventArgs e) { StiReport report = sender as StiReport; report.LoadDocument("MyFile.mdc"); } StiPreviewControl.LoadingDocument += new EventHandler(OnLoadingDocument);
VB Private Shared Sub OnLoadingDocument(ByVal sender As Object, ByVal e As EventArgs) Dim Report As StiReport = TryCast(sender, StiReport) Report.LoadDocument("MyFile.mdc") End Sub AddHandler StiPreviewControl.LoadingDocument, New EventHandler(AddressOf Form1.OnLoadingDocument)
1.13.5.2 How to process printing in the Window of Preview
How to process printing in the Window of Preview? You should use the static PrintingDocument event of the StiPreviewControl class. For processing of printing of the rendered report see below:
Š 2003-2008 Stimulsoft
Contents
217
C# private static void OnPrintingDocument(object sender, EventArgs e) { StiReport report = sender as StiReport; report.Print(); }} StiPreviewControl.PrintingDocument += new EventHandler(OnPrintingDocument);
VB Private Shared Sub OnPrintingDocument(ByVal sender As Object, ByVal e As EventArgs) Dim Report As StiReport = TryCast(sender, StiReport) Report.Print() End Sub AddHandler StiPreviewControl.PrintingDocument, New EventHandler(AddressOf Form1.OnPrintingDocument)
1.13.5.3 How to disable buttons in the toolbar
How to disable buttons in the toolbar? If you want to disable buttons in the Window of Preview you should change properties of the StiPreviewConfig service.
C# //Do this operation once when running the program StiConfig.Load(); //Get service StiPreviewConfigService config = StiConfig.Services.GetService(typeof( StiPreviewConfigService)) as StiPreviewConfigService; //Turn off all buttons of changes of the rendered report config.PageNewEnabled = false; config.PageDeleteEnabled = false; config.PageDesignEnabled = false; config.PageSizeEnabled = false; //Save configuration if necessary StiConfig.Save();
VB 'Do this operation once when running the program StiConfig.Load() 'Get service Dim Config As StiPreviewConfigService = TryCast(StiConfig.Services. Š 2003-2008 Stimulsoft
218
User Manual
GetService(GetType(StiPreviewConfigService)), StiPreviewConfigService) 'Turn off all buttons of changes of the rendered report Config.PageNewEnabled = False Config.PageDeleteEnabled = False Config.PageDesignEnabled = False Config.PageSizeEnabled = False 'Save configuration if necessary StiConfig.Save()
The same result can be get using the Configurator.exe. Besides you can use the StiPreviewControl. It contains many properties for control of visibility of various controls of the Window of Preview. For also you can use property PreviewSettings of report. You can change this property from report designer.
1.13.5.4 How to disable the toolbar
How to disable the toolbar? The toolbar can be disabled using the StiPreviewControl. Set the property of the ShowToolbar in False. 1.13.5.5 How to specify to the report generator to output the result of report rendering in the StiPreviewControl
How to specify to the report generator to output the result of report rendering in the StiPreviewControl? There are two ways of making it: The first way:
C# StiReport report = new StiReport(); report.Load("MyReport.mrt"); report.Render(); myCustomPreview.Report = report;
VB Dim Report As New StiReport Š 2003-2008 Stimulsoft
Contents
219
Report.Load("MyReport.mrt") Report.Render() MyCustomPreview.Report = Report
The second way:
C# StiReport report = new StiReport(); report.PreviewControl = myCustomPreview; report.Load("MyReport.mrt"); report.Show();
VB Dim Report As New StiReport Report.PreviewControl = MyCustomPreview Report.Load("MyReport.mrt") Report.Show()
1.13.5.6 How to specify to the report generator to use my window of report preview
How to specify to the report generator to use my window of report preview? Your window of report preview needs to have the constructor which receives at the input an object of the report. After this use the PreviewForm property of the report class. This property has the Type type. In other words your window of report preview will be created first and then displayed.
C# //Create a new window public class Form1 : Form { public Form1(StiReport report) { } } //Fill the PreviewForm property report.PreviewForm = typeof(Form1);
Š 2003-2008 Stimulsoft
220
User Manual
VB 'Create a new window Public Class Form1 Inherits Form Public Sub New(ByVal report As StiReport) InitializeComponent() End Sub End Class 'Fill the PreviewForm property Report1.PreviewForm = CType(GetType(Form1), Type)
1.13.5.7 How to set zoom of pages in the StiPreviewControl
How to set zoom of pages in the StiPreviewControl? Use the SetZoom method. For example:
C# //Set zoom 100% myPreviewControl.SetZoom(1);
VB 'Set zoom 100% MyPreviewControl.SetZoom(1)
1.13.5.8 How to set predefined zoom of pages in the StiPreviewControl
How to set predefined zoom of pages in the StiPreviewControl? You should use predefined methods for setting zoom:
C# //Display the page myPreviewControl.SetZoomOnePage(); //Display two pages myPreviewControl.SetZoomTwoPages();
Š 2003-2008 Stimulsoft
Contents
221
//Display multiple pages myPreviewControl.SetZoomMultiplePages(); //Display a page. The page is to be align by the width in the StiPreviewControl myPreviewControl.SetZoomPageWidth();
VB 'Display the page MyPreviewControl.SetZoomOnePage() 'Display two pages MyPreviewControl.SetZoomTwoPages() 'Display multiple pages MyPreviewControl.SetZoomMultiplePages() 'Display a page. The page is to be align by the width in the StiPreviewControl MyPreviewControl.SetZoomPageWidth()
1.13.5.9 How to refresh the report preview in the report code
How to refresh the report preview in the report code? Use the InvokeRefreshPreview method of the report generator:
C# this.InvokeRefreshPreview();
VB Me.InvokeRefreshPreview()
1.13.5.10 How to load a page into the rendered report from the code of the report
How to load a page into the rendered report from the code of the report? Add to the component on a page the following handler of clicking on it:
Š 2003-2008 Stimulsoft
222
User Manual
C# //Create a page StiPage page = new StiPage(); //Load the page from a file page.Load("MyPage.pg"); //Add a page to the collection of rendered pages RenderedPages.Add(page); //Refresh the window of preview InvokeRefreshPreview();
VB 'Create a page Dim Page As New StiPage 'Load the page from a file Page.Load("MyPage.pg") 'Add a page to the collection of rendered pages Report.RenderedPages.Add(Page) 'Refresh the window of preview Report.InvokeRefreshPreview()
1.13.5.11 How to get access to pages of rendered report
How to get access to pages of rendered report? Use the RenderedPages properties of a report:
C# foreach (StiPage page in report.RenderedPages) { }
VB Dim page As StiPage For Each page In MyBase.RenderedPages Next
Š 2003-2008 Stimulsoft
Contents
223
1.13.5.12 How to show all components in preview but do not print them
How to show all components in preview but do not print them? Use the Printable property: True - component will be shown in the designer and will be printed False - component will be shown in the designer and will not be printed
1.13.5.13 How to add or change an image in the rendered report in the report code
How to add or change an image in the rendered report in the report code? Add an image to your report Create and add a new component:
C# StiImage image = new StiImage(); image.Left = 0; image.Top = 0; image.Width = 10; image.Height = 10; //An image name should be unique in your report image.Name = "MyUniqueName"; //Assign the image image.Image = myImage; //Add the component with the image with the report report.Pages[0].Components.Add(image);
VB Dim Image As StiImage = New StiImage() Image.Left = 0 Image.Top = 0 Image.Width = 10 Image.Height = 10 'An image name should be unique in your report Š 2003-2008 Stimulsoft
224
User Manual
Image.Name = "MyUniqueName" 'Assign the image Image.Image = myImage 'Add the component with the image with the report Report.Pages(0).Components.Add(Image)
If the report has been compiled or loaded from assembly then, instead of the image.Image property, it is necessary to use the ImageToDraw property.
Change images in the report Let see two ways: The first way - the report is not compiled The second way - the report is compiled of loaded from assembly
The first way. Find the component with the image in the report:
C# StiImage image = report.GetComponents()["image1"] as StiImage;
VB Dim Image As StiImage = CType(Report.GetComponents()("image1"), StiImage)
Change the image:
C# image.Image = myImage;
VB Image.Image = MyImage
In this way your image will be converted to the code and then your report will be compiled and run.
The second way. Compile the report:
Š 2003-2008 Stimulsoft
Contents
225
C# report.Compile();
VB Report.Compile()
Find the component:
C# StiImage image = report.GetComponents()["image1"] as StiImage;
VB Dim Image As StiImage = CType(Report.GetComponents()("image1"), StiImage)
Assign the image:
C# image.ImageToDraw = myImage;
VB Image.ImageToDraw = MyImage
1.13.5.14 How to indicate pressing the cancel button in the Window of Preview and do not show the report
How to indicate pressing the cancel button in the Window of Preview and do not show the report? Check the IsStopped property of a report:
C# if (!report.IsStopped)
Š 2003-2008 Stimulsoft
226
User Manual
1.13.5.15 How to attach your indicator of pages rendering
How to attach your indicator of pages rendering? For attaching your indicator of pages rendering you should use the Rendering event of the report. See below the example of the code:
C# //Create a new report StiReport report = new StiReport(); report.Load("report.mrt"); //Compile this report by all means report.Compile(); //Add to the Rendering event of a compiled report report.CompiledReport.Rendering += new EventHandler(this.OnRendering); //Start report rendering. Attention! The Render method is called from False arguments. //This argument indicates that there is no need to show progress of report rendering report.Render(false); //Show the rendered report report.Show(); //The event which we are attaching private void OnRendering(object sender, EventArgs e) { StiReport report = sender as StiReport; string info = (report.PageNumber - 1).ToString(); }
VB 'Create a new report Dim Report As New StiReport Report.Load("report.mrt") 'Compile this report by all means Report.Compile() 'Add to the Rendering event of a compiled report AddHandler Report.CompiledReport.Rendering, New EventHandler(AddressOf Me. OnRendering) 'Start report rendering. Attention! The Render method is called from False arguments. 'This argument indicates that there is no need to show progress of report rendering Report.Render(False) 'Show the rendered report Š 2003-2008 Stimulsoft
Contents
227
Report.Show() 'The event which we are attaching Private Sub OnRendering(ByVal sender As Object, ByVal e As EventArgs) Dim Report As StiReport = CType(sender, StiReport) Dim Info As String = (Report.PageNumber - 1).ToString() End Sub
Attention! You have to attach to the report.CompiledReport and only after this run the Compile method. 1.13.5.16 Why the text I have printed does not look similar with the text in Preview
Why the text I have printed does not look similar with the text in Peview? Set property TextQuality of text component to the WYSIWYG (What You See Is What You Get) or to the Typographic. This property allows you to see your text in Preview as it will be printed.
1.13.6 Printing Reports
Printing Reports How to print a report immediately without preview 227 How to print report without dialog box 228 How to print a report with specified parameters 228 How to print a report with the specified printer 229 How to indicate the specified paper source for printing 230 The end of the page is not printed completely. What should I do 231 How to print copyright on every page of a report 231 Why the content of the Text is printed without last pixels 233 1.13.6.1 How to print a report immediately without preview
How to print a report immediately without preview? For a start load of a report do as follow:
C# Š 2003-2008 Stimulsoft
228
User Manual
StiReport report = new StiReport(); report.Load("report.mrt"); report.Print();
VB Dim Report As StiReport = New StiReport() Report.Load("report.mrt") Report.Print()
1.13.6.2 How to print report without dialog box
How to print report without dialog box? Use overloads of the Print method from the StiReport class.
C# StiReport report = new StiReport(); report.Load("report.mrt"); report.Render(); PrinterSettings printerSettings = new PrinterSettings(); printerSettings.Copies = 2; Report.Print(printerSettings);
VB Dim Report As StiReport = New StiReport() Report.Load("report.mrt") Report.Render() Dim PrinterSettings As PrinterSettings = New PrinterSettings() PrinterSettings.Copies = 2 Report.Print(PrinterSettings)
1.13.6.3 How to print a report with specified parameters
How to print a report with specified parameters? You may use the Print method. For example:
C# StiReport report = new StiReport(); report.Load("MyReport.mrt"); report.RegData(myDataSet);
Š 2003-2008 Stimulsoft
Contents
229
report.Render(); //Create Printer Settings PrinterSettings printerSettings = new PrinterSettings(); printerSettings.Copies = 1; printerSettings.FromPage = 1; printerSettings.ToPage = report.RenderedPages.Count; //Direct Print - Don't Show Print Dialog report.Print(false, printerSettings);
VB Dim Report As New StiReport Report.Load("MyReport.mrt") Report.RegData(MyDataSet) Report.Render() 'Create Printer Settings Dim PrinterSettings As New PrinterSettings PrinterSettings.Copies = 1 PrinterSettings.FromPage = 1 PrinterSettings.ToPage = Report.RenderedPages.Count 'Direct Print - Don't Show Print Dialog Report.Print(False, PrinterSettings)
1.13.6.4 How to print a report with the specified printer
How to print a report with the specified printer? You should specify the printer name in the PrinterName property of the PrinterSettings class. For example:
C# StiReport report = new StiReport(); report.Load("MyReport.mrt"); report.RegData(myDataSet); report.Render(); //Create Printer Settings PrinterSettings printerSettings = new PrinterSettings(); //Set Printer to Use for Printing printerSettings.PrinterName = "MyPrinterName"; //Direct Print - Don't Show Print Dialog report.Print(false, printerSettings);
VB
Š 2003-2008 Stimulsoft
230
User Manual
Dim Report As New StiReport Report.Load("MyReport.mrt") Report.RegData(MyDataSet) Report.Render() 'Create Printer Settings Dim PrinterSettings As New PrinterSettings 'Set Printer to Use for Printing PrinterSettings.PrinterName = "MyPrinterName" 'Direct Print - Don't Show Print Dialog Report.Print(False, PrinterSettings)
1.13.6.5 How to indicate the specified paper source for printing
How to indicate the specified paper source for printing? _ Use the PrinterSettings class:
C# StiReport report = new StiReport(); report.Load("MyReport.mrt"); report.RegData(myDataSet); report.Render(); //Create Printer Settings PrinterSettings printerSettings = new PrinterSettings((); //Specify paper source printerSettings.DefaultPageSettings.PaperSource = printerSettings. PaperSources[1]; //Direct Print - Don't Show Print Dialog report.Print(false, printerSettings);
VB Dim Report As New StiReport Report.Load("MyReport.mrt") Report.RegData(MyDataSet) Report.Render() 'Create Printer Settings Dim PrinterSettings As New PrinterSettings 'Specify paper source PrinterSettings.DefaultPageSettings.PaperSource = PrinterSettings. PaperSources.Item(1) 'Direct Print - Don't Show Print Dialog Š 2003-2008 Stimulsoft
Contents
231
Report.Print(False, PrinterSettings)
1.13.6.6 The end of the page is not printed completely. What should I do
The end of the page is not printed completely. What should I do? By default page margins are set to 1 cm from all sides. But some printers have more than 1 cm margins at the bottom (For example, if you are using DeskJet printers). Set the bottom margin to 2 centimetre. 1.13.6.7 How to print copyright on every page of a report
How to print copyright on every page of a report? Often you need to output copyright, system information, inscriptions, watermarks, program name, and other information which a user will not be able to delete of edit in the Designer. StimulReport.Net contains special facilities for such an output. We are talking about two static events of a page: PagePainting and PagePainted. These two events are being called when painting of a page. PagePainting is called after the page has been painted but no one component will be output. This event is used for information output on the background of a page. All information that will be output after the call of this event will overlay the information being output with event handler. The second PagePainted property. This event is called after the page has been painted completely. So, any information being output in this event handler will overlay anything that has been output on a page before. Notice. Both events are static. Therefore, if you want to output all information on all pages of a report, it is enough to assign handlers to these events. So then suppose that it is necessary to output the copyright of a company, what has created this program, on every page of a report. For this you should create the static method for the event service:
C# private static void OnPagePainting(StiPage sender, StiPagePaintEventArgs e) { }
VB Private Shared Sub OnPagePainting(ByVal sender As StiPage, ByVal e As StiPagePaintEventArgs) End Sub
Š 2003-2008 Stimulsoft
232
User Manual
Then the handler assigns to the static event of a page. Besides we make assignation once because the event is static:
C# StiPage.PagePainting += new StiPagePaintEventHandler(OnPagePainting);
VB AddHandler StiPage.PagePainting, New StiPagePaintEventHandler(AddressOf Form1.OnPagePainting)
Now it is necessary to output an inscription. All necessary information for output is contained in arguments of a called handler. By means of the sender object the reference to the page which is being painted is passed. By means of the e object parameters of output are passed. Parameters of output are to be examined more thoroughly. Thus, this argument has the StiPagePaintEventArgs type. This type contains the following fields: Name of property
Description of property
ClientRectangle
rectangle which sets size and position of the inner side of a page without page fields
FullRectangle
rectangle which sets size and position of the inner side of a page without page fields
ClipRectangle
rectangle describes size and position of range which requires to be repainted
Graphics
Graphic area on which painting occurs
IsDesigning
Boolean value. If it is true then the page is painted in the report designer
IsPrinting
Boolean value. If it is true then the page is printed
Notice. You should remember that there is no property for painting a page in the window of preview. But it is simple to check IsDesigning and IsPrinting. If both of these properties are false then the page is painted in the window of preview. The next is the code for copyright string output:
Š 2003-2008 Stimulsoft
Contents
233
C# private static void OnPagePainting(StiPage sender, StiPagePaintEventArgs e) { Font font = new Font("Arial", 20 * (float)sender.Zoom)); e.Graphics.DrawString("(C) 2005 MyCompany", font, Brushes.Red, e. FullRectangle); font.Dispose(); }
VB Private Shared Sub OnPagePainting(ByVal sender As StiPage, ByVal e As StiPagePaintEventArgs) Dim Font As Font = New Font("Arial", (20.0! * CType(page.Zoom, Single)) e.Graphics.DrawString("(C) 2005 MyCompany", Font, Brushes.Red, e. FullRectangle, Format) Font.Dispose() End Sub
In this method the copyright string is output on the page. You should consider the scale. Therefore, if you use a new font its size is corrected considering scale. Using these static events of a page painting you can output almost any information - images, text etc. 1.13.6.8 Why the content of the Text is printed without last pixels
Why the content of the Text is printed without last pixels? Set the property TextQuality to the WYSIWYG (What You See Is What You Get) or to Typographic. 1.13.7 Export of reports
Exporting reports How to export rendered report 234 How to export a report without using the dialog box 234
Š 2003-2008 Stimulsoft
234
User Manual
How to disable all unnecessary types of export from the Window of Preview 235 How to export a page with the specified size into the Bitmap 236 When I export a report to Html but not all components which are crossed have been exported 236 How, using the RichText, to output the text in the RTF format 236 The ExcelValue property 237 1.13.7.1 How to export rendered report
How to export rendered report? For exporting report to pdf file:
C# StiReport report = new StiReport(); report.Load("report.mrt"); report.Render(); report.ExportDocument(StiExportFormat.Pdf, "document.pdf");
VB Dim Report As StiReport = New StiReport() Report.Load("report.mrt") Report.Render() Report.ExportDocument(StiPdfExportFormat.Pdf, "document.pdf")
1.13.7.2 How to export a report without using the dialog box
How to export a report without using the dialog box? For exporting report to pdf file without using dialog box do the following:
C# StiReport report = new StiReport(); report.Load("report.mrt"); report.Render(); StiPdfExportService pdfExport = new StiPdfExportService(); pdfExport.ExportPdf(report, "document.pdf");
VB
Š 2003-2008 Stimulsoft
Contents
235
Dim Report As StiReport = New StiReport() Report.Load("report.mrt") Report.Render() Dim PdfExport As StiPdfExportService = New StiPdfExportService() PdfExport.ExportPdf(Report, "document.pdf")
In this example the report is being exported to pdf. You can do the same to export your report to other available formats. Use the following classes for export: StiCsvExportService - export to Csv; StiExcelXmlExportService - export to ExcelXml; StiHtmlExportService - export to Html; StiImageExportService - export to Images; StiPdfExportService - export to Pdf; StiRtfExportService - export to Rtf; StiTxtExportService - export to Txt; StiXmlExportService - export to Xml. 1.13.7.3 How to disable all unnecessary types of export from the Window of Preview
How to disable all unnecessary types of export from the Window of Preview? For this you should disable all unnecessary assemblies with exports. Also you may switch off services using the Configurator.exe application. StiConfig.Load(); StiServiceContainer services = StiConfig.Services.GetServices(typeof(StiExportService)); foreach (StiService service in services) { if if if if if if if if if if if
(service (service (service (service (service (service (service (service (service (service (service
} StiConfig.Save();
Š 2003-2008 Stimulsoft
is is is is is is is is is is is
StiBmpExportService)service.ServiceEnabled = false; StiCsvExportService)service.ServiceEnabled = false; StiEmfExportService)service.ServiceEnabled = false; StiGifExportService)service.ServiceEnabled = false; StiHtmlExportService)service.ServiceEnabled = false; StiJpegExportService)service.ServiceEnabled = false; StiPdfExportService)service.ServiceEnabled = false; StiRtfExportService)service.ServiceEnabled = false; StiTiffExportService)service.ServiceEnabled = false; StiTxtExportService)service.ServiceEnabled = false; StiXmlExportService)service.ServiceEnabled = false;
236
User Manual
1.13.7.4 How to export a page with the specified size into the Bitmap
How to export a page with the specified size into the Bitmap? Use the GetThumbnail method of a StiPage:
C# Bitmap bmp = page.GetThumbnail(200, 300);
VB Dim Bmp As Bitmap = Page.GetThumbnail(200, 300)
1.13.7.5 When I export a report to Html but not all components which are crossed have been exported
When I export a report to Html but not all components which are crossed have been exported? Export to html can work in two modes: Table and Span. In the Table mode StimulReport. Net forms a big table and write components from the page to rows of the table. But in this mode components on pages will not be crossed. In the Span mode the report engine forms span objects for each components. And in this case components will be crossed on a page. 1.13.7.6 How, using the RichText, to output the text in the RTF format
How, using the RichText, to output the text in the RTF format? In the GetValueEvent event of the RichText write the following code:
C# System.IO.StreamReader reader = new System.IO.StreamReader("d:\\script.rtf" ); string str = reader.ReadToEnd(); reader.Close(); e.Value = System.Xml.XmlConvert.EncodeName(StiRichText.PackRtf(str));
VB
Š 2003-2008 Stimulsoft
Contents
237
Dim Reader As System.IO.StreamReader = New System.IO.StreamReader("d:\ \script.rtf") Dim Str As String = Reader.ReadToEnd() Reader.Close() e.Value = System.Xml.XmlConvert.EncodeName(StiRichText.PackRtf(Str))
1.13.7.7 The ExcelValue property
The ExcelValue property The ExcelValue property is used for export numerical values to Excel. By default StiText components are exported to Excel with formatting as text. The expression in the ExcelValue property of the StiText component will be sent to the Excel cell and formatted as a number. 1.13.8 Configuration
Configuration What can I do to load or save report configuration 238 What can I do if I do not want to save configuration 238 How to restore configuration by default 238 How to use more then one configurations concurrently 238 How to save configuration in database 238 How to attach your own TraceListener 238 How to show all exceptions which are invoked in StimulReport.Net 239 How, in StimulReport.Net, to disable all dialog boxes with messages 239 How to change the current localization of the report generator 239 How to change the path to resources of localization 240 How to decrease the number of levels of relations in business objects 240 How to enable RightToLeft in the Window of Preview 240 Which units are used to store report coordinates 240 How to change the current unit in the report 241
Š 2003-2008 Stimulsoft
238
User Manual
1.13.8.1 What can I do to load or save report configuration
What can I do to load or save report configuration? You can use the Save and Load methods of the StiConfig class. 1.13.8.2 What can I do if I do not want to save configuration
What can I do if I do not want to save configuration? If you do not want to save configuration set the StiOptions.Configuration.DontSaveConfig static property in true. 1.13.8.3 How to restore configuration by default
How to restore configuration by default? Remove the Stimulsoft.Report.config file and rerun the application. After this StimulReport. Net creates file of configuration again. Also you may call the StiConfig.Restore method. This method restores configuration by default. 1.13.8.4 How to use more then one configurations concurrently
How to use more then one configurations concurrently? You should switch off the automatic save of configuration and then load and save configurations you need in proper time and proper positions. 1.13.8.5 How to save configuration in database
How to save configuration in database? Use Saving and Loading events of the StiConfig class. Write handlers and attach them to these events. 1.13.8.6 How to attach your own TraceListener
How to attach your own TraceListener? See the following:
Š 2003-2008 Stimulsoft
Contents
239
<system.diagnostics> <switches> <add name="traceLevel" value="4" /> </switches> <trace autoflush="true" indentsize="4"> <listeners> <add name="myListener" type="System.Diagnostics. TextWriterTraceListener" initializeData="C:\Inetpub\wwwroot\ambReports1\_trace.log" /> <remove type="System.Diagnostics.DefaultTraceListener"/> </listeners> </trace> </system.diagnostics>
1.13.8.7 How to show all exceptions which are invoked in StimulReport.Net
How to show all exceptions which are invoked in StimulReport.Net? Set the static StiOptions.Engine.HideExceptions property in false. 1.13.8.8 How, in StimulReport.Net, to disable all dialog boxes with messages
How, in StimulReport.Net, to disable all dialog boxes with messages? Set the StiOptions.Engine.HideMessages static property in true. 1.13.8.9 How to change the current localization of the report generator
How to change the current localization of the report generator? Use the following code:
C# //Specify the file of localization StiConfig.LoadLocalization("MyLocalization.xml");
VB 'Specify the file of localization StiConfig.LoadLocalization("MyLocalization.xml")
Š 2003-2008 Stimulsoft
240
User Manual
1.13.8.10 How to change the path to resources of localization
How to change the path to resources of localization? The directory in which StimulReport.Net searches resources of localization is set in the StiOptions.Configuration.DirectoryLocalization static property. By default this property is "Localization". If necessary you may change the value of this property. 1.13.8.11 How, in addition to English, to add other languages to localization
How, in addition to English, to add other languages to localization? Create the Localization directory in the directory where your application is located. Copy xml files which contain resources of localization. When running first StimulReport.Net will find this directory and, of course, find all files with localized resources. 1.13.8.12 How to decrease the number of levels of relations in business objects
How to decrease the number of levels of relations in business objects? You can decrease max level of relations. Use this code: StiOptions.Dictionary.Enumerables.MaxLevel = 2;//By default 10 1.13.8.13 How to enable RightToLeft in the Window of Preview
How to enable RightToLeft in the Window of Preview? To enable right to left mode for preview use the following code: StiOptions.Window.RightToLeft = StiRightToLeftType.Yes; 1.13.8.14 Which units are used to store report coordinates
Which units are used to store report coordinates? Coordinates of components of a report are stored in the current report units. They are centimeters, millimeters, inches, and hundredths of inch. For dialogs all coordinates are stored in pixels.
Š 2003-2008 Stimulsoft
Contents
241
1.13.8.15 How to change the current unit in the report
How to change the current unit in the report? For changing the current unit of a report you must use the Unit property of the StiReport class. For example:
C# //Set centimeters Report.Unit = new StiCentimetersUnit(); //Set millimeters Report.Unit = new StiMillimetersUnit(); //Set inches Report.Unit = new StiInchesUnit(); //Set hundredths of inch Report.Unit = new StiHundredthsOfInchUnit();
VB 'Set centimeters Report.Unit = New StiCentimetersUnit() 'Set millimeters Report.Unit = New StiMillimetersUnit() 'Set inches Report.Unit = New StiInchesUnit() 'Set hundredths of inch Report.Unit = New StiHundredthsOfInchUnit()
After the Unit property has been changed the report generator automatically converts all sizes and positions of components to a new unit.
Š 2003-2008 Stimulsoft