Home
FastReport.Net User's manual
Contents
1. Page Footer l In order to run the report click the gt button on the toolbar The report will be built and shown in the preview window PRODUCTS ProductName Unit Price Chal 18 Chang 19 Aniseed Syrup 10 Chef Anton s Cajun seasoning oe Chef Anton s Gumbo Mix 21 35 Grandma s Boysenberry Spread 25 Uncle Bob s Organic Dried 30 Northwoods Cranberry Sauce AU Mishi Kobe Miku a Heures 41 Example 2 Creating a report with the wizard In this example we will create a report with the help of the Standard Report Wizard For this do the following e press the nl button on the toolbar and in the Add New Item window choose Standard Report Wizard 50 Fundamentals Add New Item Report templates Blank Report Inherited Report PE wizard Label Wizard Report items a Mew Report Page New Dialog Form i Mew Data Source e on the first step of the wizard choose the Products table and click the Next button Standard Report Wizard Select datasource Select one of the available datasources or create new one 3 E Categories EJ Customers EJ MatrixDemo H E Categories BusinessObject Create new datasource e on the second step of the wizard choose the ProductName and UnitPrice data columns Fundamentals Standard Report Wizard Select data columns Select data columns that you want to show in a report Available columns Sel
2. Conversion ToBoolean Function Parameters Return value ToBoolean object value Booi Converts the specified value to boolean Example ToBoolean 1 true ToBoolean 0 false ToByte Function Parameters Return value ToByte object value byte Converts the specified value to byte Example Data 227 ToByte 55 55 ToChar Function Parameters Tohar object value Converts the specified value to char Example ToChar 65 A ToDateTime Function Parameters ToDateTime object value Converts the specified value to date time Example TODateTimet 1 1 72009 17172009F ToDecimal Function Parameters ToDecimal object value Converts the specified value to decimal Example ToDecimal 1 ToDecimal 1 1m ToDouble Function Parameters ToDouble object value Converts the specified value to double Example ToDouble 1 1 ToDouble 1 1 228 Return value char Return value DateTime Return value decimal Return value double Data Tolnt32 Function Parameters Return value RoCo object value INANE Converts the specified value to int Example TOoInts2Z LE Tolnts2 EL 1 ToRoman Function Parameters Return value ToRoman object value See WC Converts the specified numeric value to its roman representation The value must be in range 1 3998 Example ToRoman 9 IX ToSingle Function Parameters Return value ToSingle object
3. Displays the year as a maximum two digit number The first two digits of the year are omitted If the year is a single digit 1 9 it is formatted with a preceding O 01 09 Displays the year including the century If the year is less than four digits in length then preceding zeros are appended as necessary to make the displayed year four digits long Displays the time zone offset for the system s current time zone in whole hours only The offset is always displayed with a leading sign zero is displayed as 0 indicating hours ahead of Greenwich mean time or hours behind Greenwich mean time The range of values is 12 to 13 If the offset is a single digit 0 9 it is displayed as a single digit with the appropriate leading Sign Displays the time zone offset for the system s current time zone in whole hours only The offset is always displayed with a leading or trailing sign zero is displayed as 00 indicating hours ahead of Greenwich mean time or hours behind Greenwich mean time The range of values is 12 to 13 If the Data offset is a single digit 0 9 it is formatted with a preceding O 01 09 with the appropriate leading sign ZZZ Displays the time zone offset for the system s current time zone in hours and minutes The offset is always displayed with a leading or trailing sign zero is displayed as 00 00 indicating hours ahead of Greenwich mean time or hours behind Greenwich mean time
4. Filter Run the report and make sure that everything works Product name Produck name starts with Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse werte Chef Anton s Cajun Seasoning Chef Anton s Gumbo Mix Chocolade Cote de Blaye Example 6 Automatic filtering In this example we will show how to add a filter into the report which prints a product s list from the Products table We will filter the data according to the Products Discontinued column The report looks as follows r Product name L k Products ProductName Add a new dialogue into the report by pressing the button on the toolbar and drag the Products Discontinued column from the Data window onto the dialogue form 280 Dialogue forms This is all we need to do we did it just by two clicks FastReport automatically connects the control to the data column Run the report and enable the Discontinued flag After that press the OK button and you will see the report which contains only products with the Discontinued flag Product name Discontinued Alice Mutton Chef Anton s Gumbo Mix Guarana Fant stica Mishi kobe Miku Perth Pasties Rossle Sauerkraut Singaporean Hokkien Fried Mee 2244464 4 4 Th ringer Puostbratwurst Example 7 Automatic filtering by range We will show with a report from the previous example how to print products having the cost in the indicated range For that we will a
5. Appearance Filter Color scale Spatial data Size ranges Column Value Labels Analytical data Value Function Zoom the polygon Value 4017 12050 0 8033 Report creation 181 Adding map layers The Map object can contain one or more layers The layer structure is displayed in the upper left part of the editor window Click an item to set up its properties Map jy Layer 1 Layer 2 To add a new layer click on the Add button which opens the following dialog Add Layer 28 Select source ESRI shapefile D FR UNET Demos Maps world shp Embed the shapefile in the report C Empty layer with geodata provided by an application At this point choose the type of the layer from the map from an ESRI shapefile This is the most commonly used type for maps For example you can display the world map and highlight some countries in color depending on the sales level for these countries the geodata from your application Your application must provide the following data latitude longitude name and value This data is displayed as a small point on the layer The point can have a caption and can also have a variable size color dependent on the value provided In practice this type of layer is used together with a base layer
6. Select data column or type an expression Products Categories CategoryName w fe Settings You need to set the group condition This can be any expression or data source column Also choose the sorting By default data is sorted in ascending order Second method you use the wizard which can be called from the Report Group Expert menu In order to create a group enter the group condition and press the Add button 98 Report creation Group Expert Group condition Select a data column or type an expression then press Add button to add a new group Products Categories CategoryName v Se Groups Jaa ategory Name Edit gt ka The wizard will add all the elements of the group into the report Also it creates the Text object on the group header in which the group condition is printed Group Header Products Categories CategoryMarme CategoryName F Sorting the data For correct working of the group it is needed to fulfill the following condition data source must be sorted on that column which is used in the group condition If this condition is not fulfilled you will see a lot of groups containing 1 2 data rows Report creation Beverages Sasquatch Ale Steeleye Stout Seafood Inlagd Sill Gravad lax Beverages Cote de Blave Chartreuse werkte Seafood Boston Crab Meat Jack s Mew England Clam Chowder Fortunately there is a possibility of sorting t
7. Show Markers DataColumn Expression Text Description The number of segments in a code This property is set to 6 by default The size of a single code segment The default size is 0 5x1cm This property determines a distance between two segment s origins The default value is 0 9cm Determines whether it is necessary to display a grid Determines whether it is necessary to display the markers bold horizontal lines above the zipcode The data column which this object is bound to The expression that returns the zipcode data The text containing a zipcode The Cellular Text object This object can display each character of a text in its individual cell It is often used to print some forms in financial applications The object is as follows In fact this object is directly inherited from the Text object You may connect it to data in the same manner For example you may invoke the object s editor and type the following text Employees FirstName The Cellular Text object has the following properties Property CellWidth CellHeight Description These properties determine the size of a single cell If both properties are O by default the cell size will be calculated automatically depending on the font used HorzSpacing VertSpacing These properties determine the horizontal and vertical gap Fundamentals between adjacent cells 47 Your first report in the FastReport Let us create
8. e delete rename or change the visibility area of the ReportScript main class e rename a namespace in which the main class is located When the report is running the following occurs e FastReport adds into the script a list of variables whose names corresponds with the names of the report objects This is done before compiling the script and allows you to refer to the report objects by their names e an expression handler is added to the script which handles all expressions found in the report e a script is compiled if it is not empty e the script class is initialized e the report is run Script 251 Event handlers A script is mainly used for creating objects event handlers For creating event handler select the needed object In the Properties window press the 7 button in order to switch on the list of events Properties I x Text TextObject A z5 Der T B El Build BS AfterFrint BeforePrint El Preview Click Select the event you want and double click it FastReport adds an empty event handler into the report code private void Text2 PeforePrint 0b ect sender EventArgs amp The Report object has got events as well This object can be chosen by the following method e select Report in the Report Tree window e select Report in the drop down list in the Properties window In order to delete the event handler choose an event in the Properties window select the
9. enables to export pictures Appearance and size of the resulting file depends on the report template see the Recommendations on report development section Export to Excel XML Excel is an application for working with electronic worksheets It is included into Microsoft Office Export method tabular When exporting to Excel there will be a dialogue window for setting parameters of the output file Preview print export 295 Export to AML Page range all Current page Enter page numbers andfor page ranges separated by commas For example 1 5 5 12 Options Wee Silty Page breaks Open after export Export parameters e Wysiwyg the result will be as close to the report as possible If this option is disabled FastReport will reduce the number of rows and columns in the resulting file e Page breaks enables page breaks in the resulting file Appearance and size of the resulting file depends on the report template see the Recommendations on report development section Export to Excel 2007 Excel 2007 is an application for working with electronic worksheets It is included into Microsoft Office 2007 Export method tabular When exporting to Excel there will be a dialogue window for setting parameters of the output file 296 Preview print export Export to Excel 2007 Page range all Current page Enter page numbers andfor page ranges separated by commas Fo
10. j anigead Syrup eee K C PY My 10 00 We will show how to stop printing products and print just categories with the help of the dialogue For this add a dialogue into the report Double click on the OK button FastReport creates an empty event handler for the Click event Write the following code in it private void btnOk Click object sender EventArgs e Data2 Visible CheckBoxl1 Checked We will control the visibility of the band which prints the product s list In our example this is 278 Dialogue forms a band with a name Data2 If the report is run and the checkbox is unchecked we will have the following result Beverages sal cris cae ee er eee es Condiments aes ard Sarory Sauces nese soiree arid Seem ori Confections Deserta carje gi sac racks Example 5 Simple filter Let us look at the following report which prints a products list r I Product name L Products Producthame We will show in this example how to filter a products list according to the first letter of the product s name During this we will not use automatic data filtering facilities For this add a new dialog into the report and place two controls onto it LabelControl and TextBoxControl Now open the Data band editor and indicate the following filter expression Dialogue forms 279 Edit DataBand Data source Filter expression Products ProductName Starts Wwithi TextBox 1 Text
11. 180 to convert degrees to radians Example sSinto0 gt Math h ePL 7 1180F 1 210 Data Sart Function Parameters Return value SSE double d double Returns the square root of d Example Sare Ay s2 Tan Function Parameters Return value Tan double d double Returns the tangent of the specified angle d The angle must be in radians Multiply by Math PI 180 to convert degrees to radians Example Tamt4S Ma ath PL Z Leo I Truncate Function Parameters Return value Truncate double d double Truncate decimal d decimal Calculates the integral part of d Example Truncate 1 7 1 Text Note e these functions do not modify the string value passed in Instead they return a new modified string e the first character in a string has O index Keep it in mind when working with functions that take the character index such as Insert Data 211 Asc Function Parameters Return value ASC echar LAL Returns an Integer value representing the character code corresponding to a character Example Asc A 65 Chr Function Parameters Return value Clie LAL L char Returns the character associated with the specified character code Example Chr G5 TAT Insert Function Parameters Return value Insert O SELENI ENE See te liaces lt string value Inserts a value substring into the s string at a specified index position startIndex and returns a new string Example Inserts
12. AddMonths 7 29 2009 1 8 29 2009 AddSeconds Function Parameters Return value AddSeconds DateTime date DateTime double value Adds the specified number of seconds value to the date date and returns a new date Example Adaseconds 4 1729 2009 12302014 1 4772972009 1230 027 AddYears Function Parameters Return value AddYears DateTime date DateTime Lat va alue Adds the specified number of years value to the date date and returns a new date Example AddYears 7 29 2009 1 7 29 2010 Data 217 DateDiff Function Parameters Return value DateDiff DateTime datel TimeSpan DateTime date2 Returns the interval number of days hours minutes seconds between two dates Example DateDi tt 1 2 20098 gt 4il 1 2009F 1 002002 00 DateSerial Function Parameters Return value DateSerial Ig Em E a DateTime Agha lorenelaer RNE ay Creates a new DateTime value from the specified year month and day Example DateSerial 2009 7 29 7 29 2009 Day Function Parameters Return value Day DateTime date TLIC Gets the day of the month 1 31 represented by the specified date Example Day 7 29 2009 29 DayOfWeek Function Parameters Return value DayOfWeek DateTime date SrrinG Gets the localized name of the day of the week represented by the specified date Example DayOfWeek 7 29 2009 wednesday 218 Data DayOfYear Function Parameters Return value DayOfY
13. Categories CategoryName Report Report page Custom What will happen if you click this object in the preview window You will go to the object that contains specified bookmark Modify the object s appearance so it will look like a clickable link Indicate the category name as a bookmark We will define the object s bookmark later In order to print the page number in the TOC you need to do the following e enable the double pass setting of the report This can be done in the Report Options menu This needs to be done because the TOC page is printed before other pages At this moment FastReport does not know where the categories will be printed e use the Engine Get BookmarkPage function which returns page number for the specified bookmark In our case we use the Categories CategoryName expression as a bookmark name so the function call will be as follows Engine GetBookmarkPage Categories CategoryName On the second page of the report we will create a master detail report as shown in the figure below 162 Report creation Bookmark OutlineExpression Hyperlink to the Categories Category Mame Categories Category Mame page number 1 F 4 _ Product name Unit price Units in stock Discontinued oo J k L a amp Fr 4 e k i n a Products ProductName Produdis UinkPrice Products Unis ntack a L i ad ava fast repeet com T 7 ere th S ail n Pager OutlineEx
14. Example PaGRighte ABC 5 TOT ABCOO Remove Function Parameters Return value Remove SECRAG 9S SEUNG int start Index Deletes all the characters from the s string beginning at startIndex position and continuing through the last position Example Remove ABCD 3 ABC Function Parameters Return value Remove SELLING oy E EANG Ta Stare L Lndez DIONE ONE Deletes a number of characters specified in the count parameter from the s string beginning at a startIndex position Example Remove ADO0BC Ty 2 TABO Replace Function Parameters Return value Replace SE EES E string oldValue string newValue Returns a string s in which a specified substring oldValue has been replaced with another Substring newValue 214 Data Example Replace A00 TOOR BC ABCE Substring Function Parameters Return value Substring SNE SE int start Index Retrieves a substring from the s string The substring starts at a character position specified in the startIndex parameter Example Substring ABCDEF 42 TEP Function Parameters Return value USAa E SELINO Se Saa ENE EGNE EE EERE So int length Retrieves a substring fromthe s string The substring starts at a character position specified in the startIndex parameter and has a length specified in the length parameter Example Substring ABCDEF 1 3 BCD TitleCase Function Parameters Return valu
15. FastReport Net User s manual Table of contents Chapter Fundamentals The report Report designer Report options Report pages Managing pages Page properties Bands Bands in designer Configuring bands Printing Bands Band properties Report objects Common object properties The Text object Text editing Displaying the expressions Displaying the data columns HTML tags Object s properties The Rich Text object The Picture object The Line object The Shape object The Barcode object The CheckBox object The Table object The Matrix object The Chart object The Zip Code object The Cellular Text object Your first report in the FastReport Example 1 Creating a report manually Example 2 Creating a report with the wizard Chapter II Report creation Choosing data for a report Dynamic layout CanGrow CanShrink properties ShiftMode property GrowToBottom property Anchor property Dock property Formatting Table of contents 12 12 12 14 16 17 18 21 21 22 24 25 21 21 29 29 30 31 32 33 34 36 39 39 40 43 44 45 45 46 47 48 48 50 56 57 58 58 59 59 59 60 62 Border and fill Text formatting Styles Data formatting Conditional highlighting Hiding zero values Hide duplicate values Highlight odd even data rows Report with one Data band Connecting a band to data source Printing the text Sorting the data Filtering the data Data header and footer Break
16. It is necessary often to print a text whose size is not known when creating a report For example this can be a description of goods In this case the following tasks will need to be solved e calculate the height of the object such that it encloses the whole text e calculate the height of the band such that it encloses the object with a variable amount of texts e move or change the height of other objects which are contained on the band such that they do not disturb the general design of the report These tasks can be solved by using some object and band properties e CanGrow and CanShrink properties allow calculating the height of the object automatically e ShiftMode property allows moving objects that are located under the objects that expand e GrowToBottom property allows resizing an object to the bottom edge of the band e Anchor and Dock properties allow controlling the size of objects depending on the size of the band All these properties will be looked at below CanGrow CanShrink properties Every band and report object has these properties They determine whether an object can grow or shrink depending on the size of its contents If both properties are disabled the object always has the size specified in the designer These properties are very useful if it is needed to print a text whose size is not known when designing In order for an object to accommodate the entire text it needs to have the
17. You will get the following result Items sold Steven Buchanan 11 Nancy Davolio 12 Andrew Fuller 8 Janet Leverling 9 Report creation 175 Setting up auto series You can set up the chart so it will create new series automatically depending on data ina data source To set up auto series do the following e create one series and set up its properties This series will be used as a template for all new series e select Chart object and set up the auto series data column The value of this column will be a name of new series If there is no series with such name yet the new series will be added Let us demonstrate how to create auto series We will use the MatrixDemo data table to get a chart of employee s sales per year One series will represent one year To do this e connect the chart to the MatrixDemo data source e create one series and set up its data pata Name aka p x value MatrixDemo Name w fe Appearance Y value MatixDemo ItemsSold w fe Fill amp border Jx A oO O O eo n S a e on the Data processing tab check the Group by X value checkbox It is necessary because our data source has several employees with the same name e select the chart in the series list and set up its auto series column on the Data tab Data Appearance Filter Chart area Auto created series D Data column MatrixDemo Year w fe Axes Legend Title Align X values e our series
18. this option produces the monochrome TIFF file It is used only when exporting into the TIFF format Preview print export 301 When exporting several pages into one file when the Separate file for each page option is disabled the export will use a lot of CPU Memory resources Export to FTP A prepared report can be saved to an FTP server from the FastReport NET preview The report can be exported to one of the supported formats before being saved to FTP Press Save button and select FTP This opens the Save to FTP window Save to FTP as File FIP Server Username Password File Type Prepared report Settings The File tab has the following fields FTP Server enter the URL address of the FTP server Username and Password enter your username and password File Type select the file format prepared report or one of the export formats from the drop down list If an export format is selected then the Settings button becomes available which opens the settings window for the chosen export format If a proxy server is used then the URL address port username and password of the proxy server are set on the Proxy tab Save to FIP 2 Username Password 302 Preview print export When all settings have been made click the OK button to save the file to the FTP server Export to Dropbox A prepared report can be saved to a Dropbox from the Fa
19. Greater than value Greater than percent Description Only top N values are displayed All other values are collected and displayed as others value you can choose the label for this value Bottom N values are displayed If the text for the collected value is not set this value is not displayed Series values less than specified value are collected and displayed as others value Series values less than specified percent are collected and displayed as others value Series values greater than specified value are collected and displayed as others value Series values greater than specified percent are collected and displayed as others value For example to display top 5 values set up the series in the following way Collect data Value 5 E Collected text Collected color Be Sienna You will get the following result 174 Report creation Exploding the values For pie type series you can explode some values To do this select the series in the series list and switch to the Data processing tab Explode Biggest value Ww Value See You can use one of the following explode types biggest value lowest value and specific value If you choose the latter mode you have to specify a value which you want to explode It may be any expression see the Expressions chapter for details For example if you need to explode Andrew Fuller s value use the following expression Andrew Fuller
20. MS SQL Oracle Interbase Access Besides this you can use data files which are saved in xml xsd format DB table content is not saved in a report file Instead the connection string and the data Source schema are stored A connection string can contain such data as login and password that is why it is kept ciphered in a report file When needed you may increase the safety by using own key for data ciphering In this case a report file can be opened correctly only in your program Creating a data source To create a new data source choose the Data Add Data Source menu item or press the Actions button in Data window and choose the New Data Source item You will see the Data Wizard window 192 Data Data Wizard Choose database Which data connection should your report use to connect to the database Select from list of last used connections or press New connection button to create new connection MsAccess D crosstestmdb Enter the connection name Connection string Cancel First of all you are offered to create the connection For that press the New connection button You will see a window with connection settings Connection Select the connection type Connect to a database Database File De icrosstest mdb User name Password F Login prompt Test connection The following elements are shown in the figure 1 Connection type 2 If enabled the chose
21. The range of values is 12 00 to 13 00 If the offset is a single digit 0 9 it is formatted with a preceding O 01 09 with the appropriate leading sign Time separator Date separator Examples of use Format Q d MMM yyyy DateTime Now 9 Aug 2009 Format 0 MM dd yyyy DateTime Now 08 09 2009 Format 0 MMMM d DateTime Now August 9 Format 0 HH mm DateTime Now 16 07 Format 0 MM dd yyyy hh mm tt DateTime Now 08 09 2009 04 07 PM FormatCurrency Function Parameters Return value FormatCurrency object value SEEEN Formats the specified value as a currency using the Windows regional settings Example FormatCurrency 1 25 S1 259 Function Parameters Return value FormatCurrency object value SE shaver rat decima 4 Daeg Mies Formats the specified value as a currency The decimalDigits parameter indicates how many places are displayed to the right of the decimal Example Portal Currency L207 D S Sd FormatDateTime Function Parameters Return value FormatDateTime DateTime value Siang Data 225 Formats the specified value as a date time using the Windows regional settings This function does not include neutral values in the resulting string Example FormatDateTime 1 1 2009 01 01 2009 Format DatLerTaime 1 1 2000 1 50 0170172009 1230400 AM FormatDateTime 1 30 1 30 00 AM Function Parameters Return value FormatDateTime
22. Zero The following table describes the standard format specifiers for formatting the DateTime values Format Specifier d D t T Name Short date pattern Long date pattern Full date time pattern short time Full date time pattern long time General date time pattern short time General date time pattern long time Short time pattern Long time pattern Example 8 9 2009 Sunday August 09 2009 Sunday August 09 2009 2 44 PM Sunday August 09 2009 2 44 01 PM 8 9 2009 2 44 PM 8 9 2009 2 44 01 PM 2 44 PM 2 44 01 PM The following table describes the custom date time format specifiers and the results they produce Format Specifier d dd ddd dddd forF Data Description Displays the current day of the month measured as a number between 1 and 31 inclusive If the day is a single digit only 1 9 then it is displayed as a single digit Displays the current day of the month measured as a number between 1 and 31 inclusive If the day is a single digit only 1 9 it is formatted with a preceding O 01 09 Displays the abbreviated name of the day Displays the full name of the day Displays the most significant digit of the seconds fraction 223 hh HH mm MM MMM MMMM SS tt yy YYYY ZZ 224 Displays the hour in the range 1 12 If the hour is a single digit 1 9 it is displayed as a single digit Di
23. e the GBP currency is used by default e different words used when converting milliards and trilliards 230 Data Example ToWordsEnGb 121 One hundred and twenty one pounds and 00 pence Function Parameters Return value ToWordsEnGb object value SCEE string currencyName Converts the specified currency value to words in Great Britain english The currency Name parameter indicates the currency Valid values for this parameter are USD EUR GBP Example ToWordsEnGb 1024 25 EUR One thousand and twenty four euros and 25 cents Function Parameters Return value ToWordsEnGb object value SULLA string one SORO Meny Converts the specified integer value to words in Great Britain english The one parameter contains the name in singular form the many parameter contains the name in plural form Example ToWordsEnGb 124 page pages One hundred and twenty four pages ToWordsEnGb 1 page pages One page ToWordsRu Function Parameters Return value ToWordsRu object value SELNI Converts the specified currency value to words in russian Example ToWordsRu 1024 25 OnHa TEICHYUa gBaguaTb ueTbpe pyOna 25 KOneek Function Parameters Return value ToWordsRu object value Snug string currencyName Data 231 Converts the specified currency value to words in russian The currencyName parameter indicates the currency Valid values for this parameter are RUR UAH USD EU
24. independent data lists When printing such a report FastReport acts in the following way e prints the main report until the Subreport object is not met e prints the first subreport e turn to the page where the printing of subreport started from and prints the following Subreport e after all the subreports have been printed the main report continues to be printed from where the longest subreport has stopped Nested subreports On the page of a subreport you can place another Subreport object so the subreport becomes nested The number of nesting levels formally is not restricted however do not get carried away by that Multiple nesting is very difficult to understand If you have the possibility use data bands for printing nested data A Data band can have one or several nested Data bands If you need to print a report of the master detail type or master detail Subdetail there is no need to use the subreport Report creation 107 Table type reports The Table object is made up of rows columns and cells It is a simplified analog of Microsoft Excel table It looks in the following way Configuring columns You can add or delete columns with the help of the context menu For that e select the table or any of its elements and place the cursor on the needed column The cursor s form changes to a small black arrow z 4 e left click in order to select the column e right click in order to show the column s
25. structure of the report especially if it was not created by you Configure bands dlp ro i i 2 t 3 1 Report Title i Page Header Page Footer dl You can switch between these modes by clicking the button Configuring bands You can configure the bands in the Configure Bands window It can be called from the Report Configure Bands menu or with the help of the Configure bands button placed over the bands tree 22 Fundamentals Band tree Selected band s properties Configure Bands Report Title Mame ReportTitlel Page Header Bookmark Data Border Border F Page Footer CanBreak False CanGrow False CanShrink False Cursor Default Evenstyvle EvenstylePriority UseFill Fill Solid Height icm Hyperlink Hyperlink Keepchild False mu elim Kio Name The object s name Add or delete a Change order of band bands In this window it is possible to add bands into the report delete them or change their order To add a band click the Add button or right click on band tree A context menu will come up containing a list of bands A band which cannot be added is dimmed Delete Report Summary Column Header Column Footer Header Data Footer Group Header Child Overlay The Add operation depends on what band was chosen in the band tree For example adding Fundamentals 23 Data Header and Data Foo
26. text and press the Delete key Text TextObject hi AfterFPrint BeforeFrint El Preview Click ext BeforePrint Report events In order to control the report with maximum flexibility every report object has got several events For example in a handler connected to the Data band you can filter records that is hide or show the band depending on certain conditions Let us consider the events which are fired during the report generation process As an example we will take a simple report containing one page one Data band and two Text objects on the band 252 Script Products ProductName Products UnitPrice In the beginning of the report the Report object fires the StartReport event Before formation of the report page the StartPage event is fired This event is fired once for every template page do not confuse with prepared report page In our case regardless of how many pages were in the prepared report event is fired once since the template report has got one page Further printing of the Data band row starts This happens in the following way the BeforePrint band event is fired the BeforePrint event of all objects lying on the band is fired all objects are filled with data the AfterData event of all objects lying on the band is fired the BeforeLayout band event is fired objects are placed on the band the height of the band is calculated and
27. 188 Report creation Data Data Any report prints some data In FastReport you can operate with the following data data sources system variables total values report parameters expressions containing any of the above mentioned data In this chapter we will look at how to work with these data The Data window All data is accessible from the Data window This window can be shown by choosing the Data Show Data Window menu Actions x Fa E Data Sources a E System Variables Date Page TotalPages Pagel z FageNot Row AbsRow Totals T Parameters The Data window allows to operate with all data elements and also to drag them into the report page All operations can be done with the help of the toolbar and Action menu 190 Data Open Dictonary Merge Dictonary save Dictionary Choose Report Data New Data Source New Relation New Calculated Column New Parameter New Total A part of these operations is duplicated in a context menu of the Data window For example if you select a data source you can use its context menu to create a calculated column delete a data source or view its data Data sources Ordinarily the data source represents a DB table or SQL query There can be several data sources in a report For most of reports only one data source is needed A report like Master Detail needs two data sources which are connected to each
28. ABC de TL2 NAL OBC Length Function Parameters Return value Length See ES RAE Returns the length of s Example bength ABC 3 212 Data LowerCase Function Parameters Return value LowerCase SERI HS Sine Converts all characters of s to lower case and returns a result Example LowerCase ABC abc PadLeft Function Parameters Return value PadLeft Sisteu ch S7 Seiad Lart cocaLlwLehen Right aligns the characters in the s string padding with spaces on the left for a total width specified in the totalWidth parameter Example Padler ARC Dina m ABOT Function Parameters Return value PadLeft SEEPS CEE LunG REEE S E Char Padadrng har Right aligns the characters in the s string padding with paddingChar characters on the left for a total width specified in the totalWidth parameter Example P dLeft ABC 5 10T O0ABC PadRight Function Parameters Return value PaE TONE STan o Sheae shiney Log COcCalwrLeoltn Left aligns the characters in the s string padding with spaces on the right for a total width specified in the totalWidth parameter Example PAARILINE ABC y oO ABC i Data 213 Function Parameters Return value PAIR shoe hints SELLON S STERNI Tre LOCALE e Char erclielpine laeric Left aligns the characters in the s string padding with paddingChar characters on the right for a total width specified in the totalWidth parameter
29. CanGrow and CanShrink properties enabled The designer The prepared report Cangrow Canshrink true The following objects can affect the height of a band Text Rich Text Picture with AutoSize property enabled Table 58 Report creation ShiftMode property Every report object has this property This property is accessible only in the Properties window An object whose ShiftMode property is enabled will be moving up and down if the object above on can either grow or shrink The designer The prepared report The ShiftMode property can have one of the following values e Always by default Meaning that the object needs to shift always e Never Implies that the object does not need to shift e WhenOverlapped Implies that the object needs to shift in that case if the expanding object is located exactly over it that is both objects overlap horizontally This property is convenient to use when printing information in a table form when several cells of the table are located on top of each other and can have a variable amount of text GrowToBottom property Every report object has this property When printing an object with this property it stretches up to the bottom edge of a band The designer The prepared report GrowTobothom true This is needed when printing information in a table form In a table row there can be several objects which can stretch This property makes it possibl
30. Function Sum Data column or expression Products UnitsInStock Evaluate on each row of the band as Data Products Evaluate if the Following condition is met Prink on the band aas Footer Products Options Reset after print Reset if band is repeated _ Include invisible rows First of all you will be asked to indicate total s name You will be referring to the total by its name so name the total in such a way that it will be easy to understand as what it calculates Let us call our total as TotalUnits Then we choose the Sum function for the total Now we need to indicate data range for which total will be calculated For that in Evaluate on each row of the band field we choose the Data band in which a list of products is printed In the Print on the band field we choose a band in which total will be printed that is the Data Footer band Close editor by pressing OK button You will see the new total appears in the Data window Now you can drag it into the report Categories CategoryName p Product Mame Units In Stock L F 4F 4 Products Producthame Products UnitsInStack L J Q TotalUinits o When we run the report we will see the following Data 235 Beverages Condiments Product Name Units In Stock Product Name Chai 39 Aniseed Syrup Chang 17 Chef Anton s Cajun Seasoning Chartreuse werte 69 Chef Anton s Gumbo Mix Cote de Blaye 17 Genen Sho
31. LI EventiAcgs Data elements can be dragged to a script Ba g a Actions a f a Data Sources To System Variables E Totak I Parameters gl Data a Report Tree Properties a x Pictured PichuraObpact au ede i s AfterPrint BeforePrint Chick Picture 1 Click PL PvE Tiber Mouseleave Pee ee Pousalip The Code tab Event handler thak was created in the Properties window 250 In the Properties window you can create event handlers by double clicking the event Script Script language can be set in the Report Options menu This is supposed to be done just after you have created a new report because when changing the language the existing script gets deleted Report Options General Script language Description CH VisualBasic NET Script Moke iF you change the language entire script will be cleared Security Referenced assemblies Inheritance System dl System Drawing all System Windows Forms all System Data dll System ml dil General information Contrary to other report generators script in FastReport contains only what you have written In the script you can e add your variables methods and properties to the main script class e create a report object s events handler e add new classes to the script if needed A class can be added either before the ReportScript main class or after it You cannot
32. March Example 4 Conditional highlighting You can set conditional highlighting for matrix cells just like for Text object More details about this can be found in the Conditional highlighting section Let us look at Example 2 and see how to highlight an amount more than 3000 in red For this select the cell with Revenue text and press the button on Text toolbar In the conditions editor add the following condition Value gt 3000 Choose red text color for the condition A prepared report will be as follows Emplovee Year Month Andrew Fuller Janet Leverling Mancy Davolio Steven Buchanan Total 2 1 000 00 1 000 00 10 1 300 00 3 000 00 4 900 00 1999 11 2 000 00 3 100 00 1 100 00 6 200 00 12 1 200 00 1 200 00 Total 3 900 00 6 100 00 3 300 00 0 00 13 300 00 1 1 300 00 3 999 00 5 299 00 2 2 100 00 1 400 00 3 500 00 awe 3 3 200 00 43 200 00 Total 2 100 00 3 200 00 z 700 00 3 999 000 11 399 000 1 4 000 00 4 000 00 Sain 2 1 500 00 4 100 00 5 600 00 3 1 600 00 1 600 00 Total 0 00 0 00 3 100 00 3 100 00 11 200 000 1 1 800 00 1 700 00 3 500 00 oa Total 1 500 00 0 00 1 700 00 0 00 3 500 00 Total 7 800 00 9 300 00 10 800 00 12 099 00 39 999 000 As seen total values are not highlighted This occurred because we chose highlight condition for only one cell To highlight the rest of the values it is needed to set up the highlight for all mat
33. PrintRow 1 i group 1 Tablel Tablel Tablel Tablel PrintColumn PrintColumn sPreincColumn PrintColumn E E O O O il 7 ji Group 2 Tablel Tablel Tablel Tablel PrintColumn sPrintColu mn PrinctColumn PrintColumn 7 0 QO QO i 7 When we run the report we will see the following result 114 Header Header Report creation When printing the second column with the following code Tablel PrintColumn 1 the header is finished and further printing of the first column starts a new header ji group 2 Tablel PrintColumn 0Q Using totals In the dynamic mode of the Table object the following total functions are supported Function Parameters Description Sum TableCell cell Returns the sum of the values contained in cell Min TableCell cell Returns the minimum from the values contained in a cell Max TableCell cell Returns the maximum from the values contained in a cell Avg TableCell cell Returns the average of the values contained in a cell Count TableCell cell Returns the number of rows contained the specified cell In an ordinary printing mode not dynamic these functions will not work In order to use the total function place it in the cell of the table For example the following function calculates the sum of the values contained in a cell named Cell1 Sum Cell1 During this all the cells located higher and o
34. TextBoxl1 is a name of the TextBoxControl control Example 3 Handling dialogue controls By using the script and events of the controls you can handle controls just like it is done in Visual Studio We will show by example how the CheckboxControl can handle the TextBoxControl accessibility Create a new report and add a dialogue into it On the dialogue place the CheckBoxControl and TextBoxControl controls as shown in the figure below TextBox Now select the CheckBoxControl open the Properties window and click the 7 button Double click the CheckedChanged event which is fired when changing the status of the checkbox FastReport will create an empty handler for that event Write the following code in it private void CheckBoxl CheckedChanged object sender EventArgs e TextBoxl Enabled CheckBoxl1 Checked If we run the report we can enable or disable the TextBoxControl by the checkbox Dialogue forms 217 Example 4 Handling report objects Let us look at an example of a report which prints a list of categories and products in each category Beverages Salk dirbs cr eee ee ra ceed aes Chartreuse verte 13 00 Dite de Blaye 25 50 Guarana Fartiastics 450 Ipoh Cafes 4500 Lakkaliktitiri 14 00 Laughing Lumberjack Lager 14 00 Quik Lager 15 00 Ahinir u Elasbertier 775 See cuaiey Ale 14 00 Reales Seoul 14 00 Condiments wee and sawory sauces resis sarees and seesorirngs Prt ame Liit price
35. a string of the form d ddd E ddd or d ddd e ddd where each d indicates a digit 0 9 Formac Orn iO e te OOOO UOH O Onl F orf Fixed point The number is converted to a string of the form ddd ddd Data 221 Gorg Norn Porp xX or xX where each d indicates a digit 0 9 onetime te UME Oia e es NOL ts SIAN O General The number is converted to the most compact notation Bor ma teil ics Galn ir O sin Number The number is converted to a string of the form d ddd ddd ddd where each d indicates a digit 0 9 Ponce en ly Oe Ne Me Leva Ia E SSG Percent The number is converted to a string that represents a percent The converted number is multiplied by 100 in order to be presented as a percentage Ona tle 1G ie EO E a O E ny va Alaiye OHO wt Hexadecimal The number is converted to a string of hexadecimal digits The case of the format specifier indicates whether to use uppercase or lowercase characters for the hexadecimal digits greater than 9 For example use X to produce ABCDEF and x to produce abcdef For maT AET xt eG eA If you format the floating point values you may indicate a number of decimal places after the format string Format fOS Cin L22 Vso If the standard numeric format specifiers do not provide the type of formatting you require you can use custom format strings Format character 0 222 Description Zero placeholder If the value bein
36. address Employees Address phone Employees HorePhore L Employees Notes i Report page Statusbar Fundamentals The Report Tree window The Data window a A TS System Variables E Totak h Parameters The Properties window 13 Report options A window with report options can be called in the Report Options menu You will see a dialogue window with several tabs Report Options General Double pass Compress report File Use file cache Description Script P Convert null values Smooth graphics Inheritance On the General tab you can control the following report parameters Double pass parameter allows to enable two report passes This can be necessary when you use the total number of pages system variable Compress report file parameter allows saving a report in a compressed form For compressing zip algorithm is used that is why you can easily extract original contents with the help of any archive Use file cache parameter allows to save the memory when creating a report Use this parameter if your report has got a lot of pages Convert null values controls converting the null value data column into the default value O empty string false depending on the data type of a column Text quality parameter allows choosing the mode of text displaying in the report This mode does not affect printing of the report Smooth graphics parameter allows t
37. and 150 ones for crossing If we remove crossing there will be only 300 rows in the resulting table In large reports and on huge number of objects the difference will be really tremendous That of course will affect output file size When creating tables in report pay attention to neighboring cell s borders It is important that cells do not cross and arrange in layers Export filter algorithm will cut off cells but export result may be far from desirable you will see not exactly what you wanted to Arrange objects in such a way that they are placed in line vertically as well as horizontally Guidelines can help to perform this The grid alignment can also be helpful in case of cells overlapping Enable grid alignment in designer options In order to simplify alignment you can extend grid pitch Setting of grid pitch and alignment can be found in the View Options menu 308 Preview print export Options Plugins Page units Milimeters Code page Centimeters ee Inches Hundreths of inch Object markers Rectangle Corners Edit after insert Show grid Snap to grid Dotted grid Snap size Band view Structure Classic For text framing it is better to use text object s border instead of single graphic objects such as lines rectangles etc Try not to use background objects under transparent text objects Applying these simple rules will help you to create a report which will look p
38. as follows 282 Dialogue forms PRODUCT CATALOG Report Title r T T Product name Category name Unit price l l L Products ProductName Products Categories Category Name _ Products UnitPrice When we run the report we will see the following PRODUCT CATALOG Product name Category name Unit price Alice Mutton Meat Poultry 39 00 Aniseed Syrup Condiments 10 00 Boston Crab Meat Seafood 16 40 Camembert Pierrot Dairy Products 34 00 Carnarvon Tigers Seafood 62 50 Chai Beverages 16 00 Chang Beverages 19 00 Chartreuse verte Beverages 15 00 Chef Anton s Cajun Seasoning Condiments zz 00 Chef Anton s Gumbo Mix Condiments 21 55 _ Cheeolade oo oe Copfeckionss a en ee 12 75 Let us add filtering by category name For this add a new dialogue and drag the Products Categories CategoryName column onto it Actions E Data Sources H E Categories Sf Products 54 Categories CategoryID A e EE Pictur ProductIC FroductMame SupplierID Category ID QuantityPerUnit 2 UnitPrice dz UnitsInStock UnitsOnarder ReorderLevel al Miccoanmkins read n gt When creating control you will be required to select its type Choose CheckedListBoxControl If Dialogue forms 283 we run the report we will see the following dialogue CateqoarvName Beverages Condiments Confections Dairy Products Grains Cereals Meat Poultry Produce Seafood Choose
39. by pressing the Save button and selecting SkyDrive When exporting to SkyDrive for the first time the Client Information window will be displayed Client Info es Client ID Client Secret Enter the Client ID and Client Secret obtained above After clicking the OK button FastReport NET saves these values and uses them again the next time The Save to SkyDrive window has two tabs File and Proxy 306 Preview print export Save to SkyDrive ia File Prepared report Proxy The File tab contains the following fields FTP Server enter the URL address of the FTP server Username and Password enter your username and password File Type select the file format prepared report or one of the export formats from the drop down list If an export format is selected then the Settings button becomes available which opens the settings window for the chosen export format If a proxy server is used then the URL address port username and password of the proxy server are set on the Proxy tab Save to SkyDrive I N a Username Fassword When all settings have been made click the OK button to save the file to SkyDrive Report design recommendations In this chapter special design requirements of reports intended for export to other data formats will be discussed FastReport allows a great number of ways to manipulate objects during report creation Th
40. change something logo email you just open the base report and make necessary changes All other reports that inherit froma base will be changed automatically In fact when you open a report that is inherited one the base report is opened first then the inherited one Report creation 163 Creating a report To use the inheritance you need to do the following e create a base report and save it to a file e create a new report that inherits from base To create an inherited report choose the File New menu item then choose the Inherited report item in the window Add New Item Report templates Blank Report 8 Inherited Report Standard Report Wizard Label Wizard 1 Report items a Mew Report Page New Dialog Form i Mew Data Source You will be asked to select a base repor file That file must be created at this moment After that the base report will be loaded into the designer You can change it as you want You see that objects from the base report are marked with the lock sign Eb Bi Page Header Northwind traders L Page Footer Printed on Date That means you cannot delete such objects rename it or move to another band You can add new objects or bands change the object s appearance size and location When you have done save the report Changing the base report Let us look what happens if we change the base report We can e delete the object from the b
41. change this by selecting a cell and choosing the Function item in its context menu 126 Report creation Name Year Total Name Total Edit Format Hyperlink cs Function hone gt Delete Sum Min Max overage Count Choose the None function if you don t intend to print the total in the given cell In a matrix there can be one or several data cells In case the matrix has several cells they can be arranged side by side or on top of each other The CellsSideBySide property of the matrix controls how the cells are arranged It can be changed from the context menu of the Matrix object You can also choose the arrangement order when adding the second cell in the matrix When doing this look at the red indicator which shows where the second value will be placed Name Year Total Drag data here to create a new cell After you have added the second value the rest of the values will be added in the chosen order Styling the matrix In order to change the appearance of a matrix cell click on the needed cell With the help of the toolbar you can set up the font border and fill In order to change the appearance of several cells at once select the group of cells To do this select the top left cell and without leaving the mouse move the mouse so as to select the group Year oe Month Total Ha Mame Revenue Total K You can use styles in order to change the appearance of the who
42. columns repeat this sequence in order to print all the needed rows of the table Every row of the table must contain the same number of columns Keep it in mind when using the PrintColumn int index and PrintColumns int indices methods 112 Report creation The second method printing from left to right then from top to bottom This method is better for printing a table with a variable number of columns You must call the methods in the following sequence e PrintColumn column index e one or several calls of the PrintRow row number or PrintRows rows indices for printing the indicated rows e or one call of the PrintRows method for printing all rows e repeat this sequence in order to print all the needed columns of the table Every column of the table must contain the same number of rows Keep it in mind when using the PrintRow int index and PrintRows int indices methods Violation of the order of calling the printing methods leads to errors when executing the report One of the errors attempting to print the table with the help of the following code Tablel PrintRows Tablel PrintColumns This sequence of methods is not correct You must start printing the table with either the PrintRow or PrintColumn method Printing complex headers Here we are talking about headers which contain spanned cells When printing rows or columns of the table which has got spanned cells the cells automatically increase in
43. contains the displayed information As a rule it s a NAME field The world map included in the FastReport demo program contains the following fields NAME eg Germany ABBREV eg Ger ISO_A2 eg DE ISO_A3 eg DEU Other maps will have a different set of fields If the application geodata layer type is chosen set the minimum zoom value for displaying the labels The default value is 1 meaning the labels are always displayed Connecting the map layer to data Most reports use the Map object to display analytical data for example sales levels in various countries So a map layer must be connected to a data source using the map object editor window Select the layer from the layers tree and switch to the Data tab Data appropriate for the map layer type must be provided for map layer type ESRI shapefile the Data tab looks like Data Data source Sales Appearance Filter je Color scale Spatial data Size ranges Column Name O o Value Sales Country fe Labels Analytical data Value Sales SalesTotal fr Function SUMI 5 zoom the polygon Value i The data required is name eg the country name numeric value eg sales volume in this country For example a Sales data source may have this data Country SalesTotal USA 500000 Germany 1200000 Russia 300000 Set up the Data tab in the following way 184 Report creation data source Sales spati
44. context menu e if you need to select several adjacent columns left click and without leaving it move the mouse to the right or to the left in order to select adjacent columns Column s context menu can also be called in the Report Tree window Open the window select the needed column and right click the mouse Managing the size of the column You can set up the width of the column by using one of the following methods e select the table or any of its elements and place the cursor on the border between two columns The form of a cursor changes into a horizontal splitter 108 Report creation e select a column and indicate the needed width in the Width properties This property is accessible in the Properties window You can also enable the AutoSize column property When running the report the width of the column will be calculated automatically In order to limit the width of the column you can indicate the MinWidth and MaxWidth properties Width of the column should never be larger than the page s width Configuring rows Rows are configured in the same way In order to select a row do the following e select the table or any of its elements and place the cursor to the left of the needed row The cursor s form changes to a small black arrow e left click the mouse in order to select the row e right click the mouse in order to show the row s context menu If
45. encode the text in resulting file Scale X horizontal scale Scale Y vertical scale Auto Scale calculates scale X and scale Y automatically to avoid data loss 300 Preview print export Export to picture FastReport allows exporting information into the following graphical formats BMP PNG JPG GIF TIFF Windows Metafile EMF WMF Exporting method drawing When exporting into picture files a dialogue window will be offered for setting the parameters Export to Image Eg Page range all Current page Enter page numbers andor page ranges separated by commas For example 1 3 5 12 Options Format JP image hoa A Resolution 96 Jpeg quality 100 x Separate file For each page Open after export Export parameters Resolution resolution of the graphical image Use 96dpi for displaying 300dpi for printing When exporting into the TIFF format you will able to set separate values for horizontal and vertical resolution Jpeg quality JPG file compression level This option is used only when exporting into the Jpeg format Separate file for each page if the option is enabled then each report page will be exported into a separate file the name of the file will be formed on the basis of the chosen page with the given number Multi frame TIFF this option produces the multi frame TIFF file It is used only when exporting into the TIFF format Monochrome TIFF
46. expression in the object s text just as you do this in the Text object Insert the necessary data column into the text e use the DataColumn property to bind the object to the column The object has the following properties Property Description AllowExpressions This property allows to turn on or off the expression handling It is on by default Brackets This property contains a pair of symbols that designate an expression DataColumn The data column that this object is bound to Text This property contains the RTF text Padding The padding in pixels Fundamentals 35 The Picture object An object can display graphics in the following formats BMP PNG JPG GIF TIFF ICO EMF WMF With the help of the Picture object you can print your company logo a photo of employee or any graphical information The object looks like this E q1 An object can show data from the following sources Source Description Picture is loaded from a file and is saved inside the report Picture is Picture from a data column Name of the column is stored in the Data column DataColumn property Picture is loaded from a file with the given name Name of file is stored in the ImageLocation property Picture is never stored inside the report You should distribute the picture file along with the report File name Picture is loaded from the internet every time the report is created URL Image is never stored inside the report URL
47. group collections of controls Represents a Windows picture box control for displaying an image Enables the user to select a single option froma group of choices when paired with other RadioButton controls Represents a Windows rich text box control Represents a Windows text box control Displays a hierarchical collection of labeled items All controls except the DataSelectorControl are a full analog of the standard Windows Forms controls The name of the element has got a Control suffix in order to avoid duplicate names So the FastReport s ButtonControl corresponds with the standard Button control Dialogue forms 269 Referencing to a control from code Referencing to a control can be done by using its name TextBoxControll Text my text In fact the FastReport s control is just a wrapper for the standard Net control It wraps many but not all properties of the standard control If you need some property that is not implemented by the FastReport control you may access a wrapped standard control in the following way e using the Control property which is of System Windows Forms Control type TextBoxl Control as TextBox ShortcutskKEnabled false e using the property which has the same name as the control itself but without the Control suffix For example the TextBoxControl has got the TextBox property which is of System Windows Forms TextBox type and returns the wrapped TextBox control TextB
48. have several values per city Report creation 185 Highlighting data using colors After you have finished connecting a layer to its data the next question is how to display analytical data for example the sales volumes in various countries The easiest way is to set up labels displaying a country name and its sales see Setting up label display More visual impact can be achieved by painting each country with a color dependent on its sales volume For example low sales as red mid sales as yellow and high sales as green This is done by setting up the color scale on the Color scale tab Data Appearance Start color De Red zl Color scale Middle color Yelow Y Size ranges End color Be creen Labels Number of ranges 0 The color scale consists of several ranges Each range has the following properties min value max value and color You can use as many ranges as you need To set up the color scale set the number of ranges first and then the properties for each range Data Visible Appearance Start color Me Red Color scale Middle color Yellow Size ranges End color E creen Labels Number of ranges 4 Start End Color Auto Auto Transparent Auto Auto Transparent Auto Auto Transparent Y By default all range properties are set to Auto meaning FastReport calculates the minimum and maximum values for each range automatically The auto color is chosen from three pre
49. id represented by CategoryID column in the Products table Category name which we would like to print is stored in the Category Name column of the Categories table With the help of relation we can refer to the name of a category in the following way Products Categories CategoryName 202 Data For the current row of the Products table FastReport will find the corresponding parent row in the Categories table and return a value of the CategoryName column In a general case way of referring to a parent table field allows an unlimited number of table ancestors Child_table Its_parent Parent_of_a_parent And _so_on Column_name To add such a data column into a report open the Products table in the Data window You will see that among its columns there is a link to the Categories table 5 0 Products E e Categories CategoryID A CategoryMame A Description k E Picture i2 FProductID A FroductMame l2 SupplierID 2 CategoryID If we drag the column shown above into the report then we will get a Text object with a text Products Categories CategoryName Our report will be as follows Products Producthame o Products Categories CategoryName a Sere en Rien rene nT ay enn nen i anne If we run it we will see the following Slice Mutton Meat Poultry 4niseed Syrup Condiments Boston Crab Meat Seafood Camembert Pierrot Dairy Products Carnarvon Tigers Seafood Ch
50. is not Known beforehand how many rows and columns will be in the matrix this depends on the data to which it is connected The object looks like this Revenue You can learn more about this object in the Creating reports chapter The Matrix object has the following properties Property Description RepeatHeaders If matrix is divided on several pages this property allows printing matrix header on each new page CellsSideBySide This property determines how matrix cells will be located if the matrix has several data cell levels Possible variants e the cells are displayed side by side e the cells are displayed under each other Style Using this property you can set a style for the whole matrix You can choose one from predefined styles AutoSize This property allows to calculate the matrix size automatically Disable it if you want to control the object size manually DataSource The property allows connecting the matrix to the data source This property is set up automatically when you drag data column to the matrix However if you use expressions in cells check that this property was set up correctly Filter This property contains expression for data filtering which will be applicable to data source of the matrix see DataSource property The Chart object The MS Chart object allows to display charts There are more than 30 different series types available bars columns areas lines bubbles pie
51. is stored the in the ImageLocation property In order to call a picture editor double click on the object In the editor you can choose the data source for the picture 36 Fundamentals Edit Picture Picture E Load Paste lt 2 Clear Data column File name Hyperlink l 1 x 111 In order to bind the object to a data column click on the small button in the upper right corner of the object and choose the data column from a list Mone Category IO L Al CategoryNarme Description Picture You also can drag amp drop a data column from the Data window into the report page In this case the Picture object is created which contains a link to the column The column you drag Should have the byte data type In the context menu of the Picture object you can choose the size mode AutoSize The object gets the size of the picture Centerlmage The picture is centered inside the object Normal The picture is displayed in the left corner of the object StretchImage The picture is stretched to the size of the object Zoom The picture is stretched to the size of the object in accordance with the aspect ratio The difference between modes is shown in the following picture Fundamentals 37 SizeMode AutosSize SizeMode Center SizeMode Normal 7 Fa SizeMode Stretch SizeMode Zoom The Picture object has the following properties Property Angle SizeMode Transparency Tra
52. it is an integer variable And it is so We know that all expressions are compiled All non standard things like referring to data columns froma compiler s point of view are converted into another type which is understandable to a compiler So the last expression will be turned into the following form string Report GetColumnValue Employees FirstName int Report GetColumnValue Employees Age ToString As seen FastReport changes reference to data columns in the following way Employees FirstName gt string Report GetColumnValue Employees FirstName Employees Age gt int Report GetColumnValue Employees Age That is we can use data column in an expressions as if it is a variable having a definite type For example the following expression will return the first symbol of an employee s name Employees FirstName Substring 0 1 Reference to system variables You can use the following system variables in expressions they are accessible in the Data window Variable Net data type Description Date DateTime Date and time of the report s start Page int Current page number int Total number of pages in the report To use this TotalPages variable you need to enable the report s double pass You can do this in Report Properties menu PageN string Page number in the form Page N PageNofM string Page number in the form Page N of M STE int Data row number inside the group
53. method has three parameters each of which is an array of System Object type The first parameter is a column value the second one is the row value and the third one is the cell value Note that the number of values in every array should comply with the object s settings In our case an object has one level in column row and cell correspondingly we supply one value for columns one for rows and one for cells When we run the report we will see the following Report creation 141 Let us demonstrate how to add a value 21 to the matrix at the intersection of column 7 and row 3 For that change a code in the following way private void Matrixl ManualBuild object sender EventArgs e object columnValues new object 1 object rowValues new object 1 object cellValues new object 1 ror Ine i S 2s L lt 10S IFF columnValues 0 i rowValues 0 i cellValues 0 i Matrixl AddValue columnValues rowValues cellValues columnValues 0O 7 rowValues 0 3 cellValues 0O 21 Matrixl AddValue columnValues rowValues cellValues As a result we have the following 142 Report creation As seen the matrix automatically calculates the totals You can use the ManualBuild event handler for the matrix which is connected to data In this case event handler is called first then the matrix is filled with data from the data source Report creation 143 Interactive reports A Fas
54. object editor Adding map layers Setting up the layer appearance Setting up label display Connecting the map layer to data Highlighting data using colors Highlighting data using size Chapter Ill Data The Data window Data sources Creating a data source Creating a SQL query Query parameters Passing a value to the parameter Editing a connection Editing a data source Aliases Hierarchical data sources Relations Creating a relation Editing a relation System variables Functions Mathematical Abs Acos Asin Atan Ceiling Cos Exp Floor Log Maximum Minimum Round Sin 168 169 171 172 173 174 175 176 177 180 180 180 181 182 183 183 184 186 187 190 190 191 192 195 197 198 199 199 200 200 201 204 204 205 206 206 206 207 207 207 208 208 208 208 209 209 209 210 210 Table of contents Sart 211 Tan 211 Truncate 211 Text 211 ASC 212 Chr 212 Insert 212 Length 212 LowerCase 213 PadLeft 213 PadRight 213 Remove 214 Replace 214 Substring 215 TitleCase 215 Trim 215 UpperCase 216 Date amp Time 216 AddDays 216 AddHours 216 AddMinutes 217 AddMonths 217 AddSeconds 217 AddY ears 217 DateDiff 218 DateSerial 218 Day 218 Day OfW eek 218 Day OfY ear 219 DaysInMonth 219 Hour 219 Minute 219 Month 220 MonthName 220 Second 220 Year 220 Formatting 221 Format 221 FormatCurrency 225 FormatDate Time 225 FormatNumber 226 FormatPercent 22 Conversion 227 ToBoolean 22 ToByte
55. objects are visible Shapel Visible true Shape2 Visible value gt 100 Shape3 Visible value gt 3000 Choose the color of objects value lt 100 red color value lt 3000 yellow color value gt 3000 green color Color color Color Read if value gt 100 color Color Yellow if value gt 3000 color Color GreenYellow Report creation 139 Set the objects color Shapel Fill new SolidFill color Shape2 Fill new SolidFill color Shape3 Fill new SolidFill color When we run the report we will see the following Employee 1999 000 001 2002 Total Andrew Fuller EHE 5900 00 HEHE 2 i0000 m EE 1 600 00 7 o00 00 Janet Leverling EEE 2 66100 00 BEE 3200 00 m E 3 300 00 Nancy Dayolio EEE 33500 00 EE 2 700 00 EESE 3100 00 1 700 00 10 800 00 Steven Buchanan W HEHE 999 00 BEE 68100 00 m 1z 099 00 Total 13 300 00 11 999 00 11 200 00 3500 00 39 999 00 Example 9 Filling a matrix manually In all the examples we have looked at the matrix was filled with data automatically because it was connected to data source Data source for the matrix is indicated in the DataSource property Though we did not set the value of this property manually it occurred implicitly while adding data columns to the matrix Using script it is possible to fill in the matrix manually For this it is needed to create the ManualBuild event handler of the matrix Call AddValue method in the handle
56. of the page ColumnFinished The object s value will be calculated at the end of the column DataFinished The object s value will be calculated at the end of the data band when its footer is printed GroupFinished The object s value will be calculated at the end of the group when its footer is printed Let s look at how it works Put the Text object which prints the total on the group header Set the ProcessAt property of the Text object to GroupFinished Data 237 Process4t GroupFinished Products Producthame L Total products TotalProducts When you run the report FastReport will do the following e it will print the group header The total value will be printed as O wrong but FastReport will remember this object to process it later e it will print all data rows e it will print the group footer At this moment FastReport will take the object that was printed in the group header and process it again to print the correct total value The prepared report will be as follows Alice Mutton 39 00 Aniseed Syrup 10 00 Total products 2 Boston Crab Meat 16 40 Total products 1 Camembert Pierrot 34 00 Carnarvon Tigers 62 50 Chai 18 00 E at eT ee Oe eee 19 00 Using other values of the ProcessAt property you may print the report total in the report title set ProcessAt ReportFinished or print the page total in the page header set ProcessAt Pa
57. or more than the given In order to indicate how to interpret the value entered in the element use the FilterOperation property looked at above Using two controls which are connected to the same data column and have got different settings of the FilterOperation property you can indicate the beginning and the ending of the data range For the first control you need to indicate the FilterOperation GreaterT hanOrEqual for the second LessThanOrEqual Filtering on related data column As we know between two data sources a relation can be set See more details in the Data chapter With the help of relation it is possible to filter data in the source by using a data column froma different source Assuming you have placed on the dialogue a ListBoxControl and indicated the following data column in the DataColumn property Products Categories CategoryName How will filtering work e when filling the control with values the CategoryName column from the Categories data source will be used e the filter will be applied to the Products table Those data rows will be filtered for which the following condition is correct the Products Categories CategoryName contains one of the values selected by the user Filtering using cascading lists A cascading list is a list with choices that change based on the value a user selects in another list For example you have two lists on a form one with categories another on
58. other using a relation we will learn about it later in this chapter Data source has one or several data columns Each column has a definite data type To look at column type select it and open the Properties window Column type is indicated in the DataType property The icon near the column name also helps to determine its type There are two ways to define a data source for the report The first method data source is defined in the application and registered in a report It s up to the programmer who created this application see details in the Programmer s manual A user should only choose the needed data source in order to use it in a report It can be done in the Data Choose Report Data menu Data 191 Choose Report Data Select data sources and fields that you want to use in the report Categories 1E Customers 1E Employees 1E Order Details 1E Orders ME Products 1E Shippers 1E Suppliers 1E MatrixDemo E Categories BusinessObject Show alases All data registered in a report is listed in this window Just tick off those data which are needed in your report It can be done at any moment while working with a report The second method you create a new data source yourself It can be a DB table or a SQL query In such a case data source definition is saved in a report file FastReport allows connecting to many popular DBMS data base management systems such as
59. p 10677 k Blauer See Delikatessen TE _ Blondel p re et Fils Bolido Comidas preparadas Lig ri Bon app h Bottom Dollar Markets B s Beverages h Cactus Comidas para levar e Centro comercial Moctezuma Ei Chop suey Chinese lt opel i mir cK ep Ee as This control shows a tree structure which was formed during the report building If you click the tree element you will navigate to the corresponding report element If the report has got an outline it will be shown automatically You can show or hide the outline by clicking the H button on the toolbar The report does not create an outline automatically you should take care about this The report page and all its bands have the OutlineExpression property To fill the outline indicate an expression which returns the element s text in this property This expression will be calculated when printing a band and its value will be added to the outline If your report is of master detail or group type the structure of the outline will be similar to the report s structure The OutlineExpression property can be set in the Properties window Here are the recommendations on how to configure the outline for different types of reports Report creation 149 e if you want to show the sheets of a prepared report in the outline set the OutlineExpression property of the report page The expression will return the number of the page PageN e in the Simple l
60. properties i Ss Chart A al Series 1 Column f iii i T Series2 Line O Series3 Doughnut To add a new series press the Add button You will see the Gallery dialog 168 Report creation Bar amp Column Area Line Point amp Bubble Pie Circular Financial Pyramid amp Funnel i 100 Stacked Bar F F ma Di i b Lo fe Pg iL d Dlr ro a i o z af Li i J 1 T pm IE E Stacked Bar aA Column EEJ EE ct amp J 1 Tha j 2 m E i z 1 i r m 1 i H ro m l F P Stacked Column 100 Stacked Column Cancel _ Add new chart area for this series Select the needed category then needed series type If you want to place the series in its own chart area check the Add new chart area for this series checkbox For some series types such as pie circular financial pyramidal the new chart area is added automatically regardless of this checkbox state To delete the series press the Delete button To change series order use Up and Down buttons Setting up the appearance Using the chart editor you can set up appearance of each chart element All properties more than 100 are splitted in several categories Some of them are specific to Chart object while others are part of
61. several categories and click the OK button After this the data will be filtered and you will see the following report PRODUCT CATALOG Product name Category name Unit price Camembert Pierrot Dairy Products 34 00 Chai Beverages 18 00 Chang Beverages 19 00 Chartreuse werte Beverages 16 00 Cote de Blave Beverages 263 50 Flatemysost Dairy Products 21 50 Geitost Dairy Products 2 50 Gorgonzola Telina Dairy Products 12 50 Guarana Fantastica Beverages 4 50 Gudbrandsdalsost Dairy Products 36 00 Ipoh Coffee Beverages 46 00 he alikAaet i Reverages l 18 00 As seen only products have remained which are in the chosen category 284 Dialogue forms Preview print export Preview print export A built report can be shown on the screen printed on the printer or exported into one of the Supported formats All these can be done in the preview window bee AA ee i on ia Toolbar EJ Preview Report pages Brn EAs GADAA DM 4 lot b Pl cose Beverages Chai Sues Chang Chartreuse verte Cote de Blaye Guarana Fant stica Ipoh Coffee Lakkalik ri Laughing Lumberjack Lager Outback Lager Rh nbr u Klosterbier Sasquatch Ale Steeleye Stout Condiments Confections Dairy Products Grains Cereals Meat Poultry Produce Seafood Page 1 of 4 I L 1 Po ee Pe eo DyYN PEP RE RT ET TREF a eee er ee ee E Pa A B cop ll iy
62. simple report having the following appearance Products ProductName Products UnitPrice Select the object which prints the UnitPrice column and create a BeforePrint event handler Privace void Text2 BerorePrint ebject Sender EventArgs amp if Decimal Report GetColumnValue Products UnitPrice gt 20 Text2 TextColor Color Red In order to insert the Products UnitPrice data column into the script drag it fromthe Data window During this the following string will be added in the script Decimal Report GetColumnValue Products UnitPrice If we run the report we will see that all the products having the price gt 20 are highlighted in red Chai 16 00 Chang 19 00 Aniseed Syrup 10 00 Chef Anton s Cajun Seasoning 22 00 Chef Anton s Gumbo Mix 21 35 Grandma s Boysenberry Spread 25 00 The same effect can be achieved with the help of the conditional highlighting you can read more about this in the Conditional highlighting section of the Report creation chapter Script 261 Example 2 Highlighting even rows of the band In this example we will show how to change the fill color of the Data band s even rows We will be using e BeforePrint band event e reference to the Row system variable from the script Create a simple report having the following appearance Create a BeforePrint event handler for the band private void Datal BetorePrint abject
63. size We will show this in the next example Header We will create a ManualBuild event handler which will be printing the first column 3 times and the second column 1 time Private void Tablel ManualBuild ebjecu sender EventArgs e f f p einting row 1 and columns O U 0 1 Tablel PrintRow 0 Tablel PrintColumn Tablel PrintColumn Tablel PrintColumn Tablel PrintColumn 7 O O O Ab 0 0 0 1 P Finting row 1 and columns 0 0 O 1 Tablel PrintRow 1 Tablel PrintColumn Tablel PrintColumn Tablel PrintColumn Tablel PrintColumn 7 0 0 0 aL 7 Report creation 113 Pay attention that we have printed the same number of columns in every row If this rule is violated then we will get an unpredictable result As a result of executing this code we will get the following Header As seen the header cell is spanned automatically We will make the code a little more complex so that two groups of columns can be printed private void Tablel ManualBuild object sender EventArgs e print 0 row and two groups of O 0 O0 1 columns Tablel PrintRow 0 77 group 1 Tablel PrintColumn Tablel PrintColumn Tablel PrintColumn Tablel PrintColumn jy group 2 e 7 e e 0 0 0 1 Tablel Tablel Tablel Tablel print 1 row and two groups of 0 Or O Tablel PrintColumn PrincColumn sPrintColumn PrinctColumn i columnes
64. source by its name initialize data fill the ListBoxControl with the data from data source after choosing the employee build a filter expression that will be used in the Data band FastReport can do this automatically For this automatic filtering is used which we will observe now Automatic filtering how it works Control is connected to the data column using the DataColumn property If the control can display a list of values for example ListBoxControl it fills with values from the indicated data column This happens automatically when the dialogue is shown Further the user works with the dialogue selects one or several items in the control and closes the dialogue At this time the data source which was indicated in the DataColumn property is filtered automatically The advantage of this method is that you can use it in any report without writing any code Automatic filtering is supported by the following controls Icon Name CheckBoxControl CheckedListBoxControl Dialogue forms 271 Ea ComboBoxControl nin DataSelectorControl a DateT imePickerControl ListBoxControl e MaskedTextBoxControl Ea MonthCalendarControl E Numeric UpDownControl RadioButtonControl TextBoxControl Filter operations By default FastReport filters the data rows which contain the value equal to the value of the control This behavior is defined in the FilterOperation property of the control You can use the f
65. system variables that can be used in a report Variable Date Page TotalPages PageN PageNofM Row AbsRow Page TotalPages HierarchyLevel HierarchyRow Data Description Date and time of the report s start Current page number Total number of pages in the report To use this variable you need to enable the report s double pass You can do this in Report Properties menu Page number in the form Page N Page number in the form Page N of M Data row number inside the group This value is reset at the start of a new group Absolute number of data row This value is never reset at the start of a new group Current page number If you join several prepared reports into one package this variable will return current page number in a package This variable is actually a macro It value is substituted when the component is viewed in the preview window That means you cannot use it in an expression Total number of pages in the report If you join several prepared reports into one package this variable will return the number of pages in a package You don t need to use double pass to get the correct value This variable is actually a macro It value is substituted when the component is viewed in the preview window That means you cannot use it in an expression Current level of hierarchy in a hierarchical report see Printing hierarchy The top level is equal to 1 Full row number l
66. the current position which is determined by the X and Y coordinates This position is retuned by the Engine CurX and Engine CurY properties After printing a band CurY automatically increases by the height of the printed band After forming a new page the position of the CurY is set to 0 The position of the CurX changes when printing a multicolumn 256 Script report Engine CurX and Engine CurY properties are accessible not only for reading but also for writing This means that you can shift a band manually by using one of the suitable events Examples of using these properties can be seen in the Examples section When working with properties which return the size or position remember that these properties are measured in the screen pixels In the Engine object the following methods are defined Method Description void AddOutline string text Adds an element into the report outline read the chapter Interactive reports and sets the current position to the added element void OutlineRoot Sets the current position on the root of the outline roel Ome a a Shifts the current position to a higher level outline element void AddBookmark string name Adds a bookmark read the chapter Interactive reports int GetBookmarkPage string na Returns the page number on which the bookmark with the indicated name is placed void StartNewPage Starts a new page If the report is multicolumn a new column is started By
67. the report template On each page you can place a Separate report To add a new page click the al button on the toolbar A page can also be added by pressing the Add New button and selecting the Report page item in the window For creating the Table of Contents section you can use the technique described in the Interactive reports chapter Page settings In the Page Setup window you can indicate that FastReport should mirror the left and the right margin for even pages Page Setup FP a Left Margins Top Right Source Bottom Columns Mirror margins on even pages ther If you need to start the page on an odd page number set the StartOnOddPage property to true When needed FastReport prints the empty page before starting to print the indicated page 92 Report creation Printing on odd even pages All report objects have the PrintOn property Using this property you can print different objects on odd and even pages This property can be set in the Properties window This property determines on which pages the object can be printed The property can have one of the following values or any combination of it FirstPage LastPage the report must be double pass OddPages EvenPages RepeatedBand This value refers to a band with the RepeatOnEveryPage property set to true e SinglePage the report must be double pass By default the value of this property equals to FirstPa
68. to pass a selected category from the main report to the detailed one For category identification we will use the CategoryID column which is contained in both Categories and Products tables Configure the parameter in the following way Data Actions ro x E3 Data Sources System Variables Totals I TE Parameters B SelectedCategory Data t Report Tree Properties SelectedCategory 321 Bl7 El Data DataType String Expression El Design Mame SelectedCategory ax Now we need to set data filtering to filter all products that belong to the specified category To do this double click the Data band Switch to the Filter tab and indicate the following condition 152 Report creation Edit DataBand Data source Filter expression Products Categories CategoryName SelectedCategory je Filter Now create the main report Create a new report and choose the Categories table as a data source Place the objects in the following way Report Title Right click on the Text object and select the Hyperlink menu item Set up the link in the following way Report creation 153 Edit Hyperlink URL Report name detailReport Fro Page number a Report parameter Bookmark SelectedCategoary we Report Specify a parameter value Report page pT or enter the expression that returns a parameter value Custom Categories CategoryHame je What will happen if
69. using the AddOutline OutlineRoot OutlineUp methods you can form the report outline manually Usually this is done automatically with the help of the OutlineExpression property which every band and report page have got The AddOutline method adds a child element to the current outline element and makes it Current The current report page and the current position on the page are associated with the new element If you call the AddOutline method several times then you will have the following structure Item1 Item2 Item3 For controlling the current element there are OutlineUp and OutlineRoot methods The first method moves the pointer to the element located on a higher level So the script Engine AddOutline Item1 Engine AddOutline Item2 Engine AddOutline Item3 Engine OutlineUp Engine AddOutline Item4 will create the following outline Item1 Item2 Item3 Script 257 Item4 The OutlineRoot method moves the current element to the root of the outline For example the following script Engine AddOutline Item1 Engine AddOutline Item2 Engine AddOutline Item3 Engine OutlineRoot Engine AddOutline Item4 will create the following outline Item1 Item 2 Item3 Item4 For working with bookmarks the AddBookmark and GetBookmarkPage methods of the Engine object are used Usually bookmarks are added automatically when using the Bookmark property which all objects of the
70. will not be added before the first group This is done in order to avoid an empty first page The ResetPageNumber property allows resetting the page number when printing the group Usually it is used together with the StartNewPage property As a result if both of these properties are enabled every group will be printed on a new page and will have its own page numeration Report creation 105 Subreports Sometimes at a certain place of the main report extra data needs to be shown this can be a Separate report with a very complicated structure You can try to solve this task by using FastReport s rich collection of bands However in certain cases it is preferable to use the Subreport object The Subreport object is an ordinary report object which can be placed on one of the bands When you do this FastReport adds an extra page into the report and connects it with the Subreport On this page it is possible to create an extra report having any structure When printing the report in which there is the Subreport object the following will be done 1 The main report will be printed while the Subreport object is not met 2 The subreport bands will be printed 3 Printing of the main report will continue Since subreport is formed on the sheet of the main report it cannot contain the following bands Report header footer Page header footer Column header footer Overlay Printing modes Subreport can be prin
71. window which will open select Data band Report Title Page Header Delete Report Title Report Summary Column Header Column Footer ean Header After this a nested Data is added to the selected band Close the window by pressing the Close button You will see that the report template changes in the following way Configure bands djb ro i i 2 t 3 1 Report Title Page Header Page Footer Nested data bands are clearly seen on band structures on the left part of the window After this you need to connect the band to the corresponding data source and place data columns on the bands We will be using two data sources Categories and Products from the demo data base which comes with FastReport Configure bands dlp i ai Fo ot 3 bt 4 ai 5S yar GI F 4b B 1 _ Categories Category Name J H Categories Description L i ProductName UnitPrice Products ProductName T Products UnitPrice 84 Report creation If we run the report we will see the following Beverages Soft drinks coffees teas beers and ales ProductName UnitPrice Chai 18 00p Chang 19 00p Guarana Fant stica 450p Sasquatch Ale 14 00p Steeleye Stout 16 00p Cote de Blaye 263 50p Chartreuse verte 16 00p Ipoh Coffee 46 00p Laughing Lumberjack Lager 14 00p Outback Lager 15 00p Rh nbr u Klosterbier 775p Lakkalik ri 15 00p Condiments Sweet and savory sauces rel
72. you need to select several adjacent rows then left click the mouse and without leaving it move the mouse to right or to the left so as to select the adjacent rows Managing the size of the row You can set up the height of the row by using one of the following methods e select the table or any of its elements and place the cursor on the border between two rows The cursor s form changes into a vertical splitter Left click and move the mouse in order to change the size of the row e select the row and indicate the needed height in the Height property This property is accessible in the Properties windows You can also enable the row s AutoSize property When the report is run the height of the row will be calculated automatically In order to limit the height of the row you can use the minimum height MinHeight and Maximum height MaxHeight properties Height of the row should never be larger than the page s height Report creation 109 Configuring cells Cells are text objects In essence the cells class is inherited from the Text object Everything which has been said above about the Text object applies to the table s cells as well Editing the cells text can be done just like the Text object Besides you can drag and drop an element from the Data window into the cells Border and fill of a cell can be configured with the help of the Border and Fill toolbar In order to call a cell s conte
73. 19 00 4niseed Syrup 10 00 Konbu 6 00 Genen Showy 15 50 Pavlova 17 45 The same effect can be achieved by using the data filter which can be set in the Data band editor Example 4 Calculating total In this example we will show how to calculate the sum by using programming methods We will use the following e BeforePrint band event e reference to the data column froma script e local variable whose value will be printed in the report Create a report of the following form _ Products ProductName TOO Products UnitPrice Report Summary gt Total surm In the script declare the sum variable and create a BeforePrint event handler belonging to the band Script 263 public class ReportScript private decimal sum Private Void Datal BerorePrint ab ject sender EventArgs sum Decimal Report GetColumnValue Products UnitPrice The Products UnitPrice data column can be placed into the script dragging it from the Data window If you run the report you will see the following R d Kaviar 15 00 Longlife Tofu 10 00 Rh nbr u klosterbier Pyro Lakkalik dri 15 00 Original Frankfurter gr ne Sate 13 00 Total 2222 71 The same effect can be achieved by using totals Example 5 Shifting the print position In this example we will show how to shift the position of a band manually by using the Engine object We will be using e BeforePrint band event e Engine ob
74. 22 ToChar 228 ToDateTime 228 ToDecimal 228 ToDouble 228 Tolnt32 229 Table of contents 7 ToRoman ToSingle ToString ToWords ToWordsEnGb ToWordsRu Program Flow Choose lif Switch Totals Creating a total Conditional totals Running totals Page totals Printing the total in the header Report parameters Creating a parameter Using parameters in a report Chapter IV Expressions Expression editor Reference to report objects Using Net functions Reference to data elements Reference to data sources Reference to system variables Reference to total values Reference to report parameters Chapter V Script General information Event handlers Report events Using Net objects Reference to report objects Report and Engine objects Reference to data sources Rererence to system variables Reference to total values Reference to report parameters Examples Example 1 Changing object s appearance Example 2 Highlighting even rows of the band Example 3 Data filtering Example 4 Calculating total Example 5 Shifting the print position Chapter VI Dialogue forms Controls 229 229 229 230 230 231 232 232 233 233 233 234 236 237 237 237 238 239 239 242 243 243 244 245 245 246 247 247 250 251 252 252 253 254 255 258 259 259 259 261 261 262 262 263 264 268 268 Table of contents Referencing to a control from code Data filtering Automatic filtering how it works Filte
75. 27 18 Taddress gt Hound Phone 71 555 w a a a he oe amp on SD Aes 2 2 et Anne has a BA degree in Ep oe oe a ANC After editing close the designer When doing this you will be asked to save the changes in the report page Printing the report In order for print a report press the button or press a combination of Ctrl P You will see the print dialogue 288 Preview print export Printer Microsoft Office Document Image Writer Settings _ Print to file Page range Copies All Coun Current page Enter page numbers andor page ranges separated by commas For example 1 5 5 12 Okher Frink mode Print Order Duplex Source Default We will look at the settings accessible in this dialogue The button More Less allows showing the whole dialogue or just the basic settings By default a dialogue is shown in a simple form Printer group here you can choose the printer change its settings Settings button and choose print to the file Page group here you can choose which pages to print all current or the given page number Copy group here you can set the number of copies and choose the order of the pages in the copies Collate Others group here you can choose which pages to print all even odd choose the order of printing direct reverse set up the duplex printing if your printer supports it and choose the paper source Print mod
76. C BAD TOLNA EAG Pakams Obec args Replaces the format item in a specified format string with the value of a corresponding Object instance in a specified args array For example the following function call Format Name 0 hours 1 hh myName DateTime Now contains the following format items O and 1 hh They will be replaced with values of myName and DateTime Now The result may look as follows Name Alex hours 12 Each format item takes the following form index alignment formatString e index a zero based integer that indicates which element in a list of objects to format e alignment an optional integer indicating the minimum width of the region to contain the formatted value If the length of the formatted value is less than alignment then the region is padded with spaces If alignment is negative the formatted value is left justified in the region if alignment is positive the formatted value is right justified e formatString an optional string of format specifiers The following table describes the standard numeric format strings Se UTE Name Description Specifier Corc Currency The number is converted to a string that represents a Currency amount Bommac es Or ott en Our hol OmO 0 Dord Decimal This format is supported for integral types only The number is converted to a string of decimal digits 0 9 Forme aur Da Wee nli One tan Eore Scientific The number is converted to
77. DateTime value ERG SEEL TOCMAI Formats the specified value as a date time using the named format specified in the format parameter The valid values for this parameter are Long Date Short Date Long Time Short Time Example FormatDateTime 1 1 2009 1 30 Long Date Thursday January 01 2009 FormatDateTime 1 1 2009 Short Date 01 01 2009 FormatDateTime 1 30 Short Time 01 30 AM FormatDateTime 1 30 Long Time 1 30 00 AM FormatNumber Function Parameters Return value FormatNumber object value SELENO Formats the specified value as a number using the Windows regional settings Example FotmatNumber 1234 296 17234 50 Function Parameters Return value FormatNumber object value SEO Teede CI Mma DIG EES Formats the specified value as a number The decimalDigits parameter indicates how many places are displayed to the right of the decimal Example FormatNumber 1234 56 1 1 234 6 226 Data FormatPercent Function Parameters Return value FormatPercent object value Sesser Formats the specified value as a percent using the Windows regional settings Example FormatPercent 0 15 15 00 Function Parameters Return value FormatPercent object value SEAT ENE EEM DEES Formats the specified value as a percent The decimalDigits parameter indicates how many places are displayed to the right of the decimal Example FormatPercent 0 15 0 15
78. HT file web archivet 2 ML Excel table Excel 2007 file PowerPoint 2007 file CpenOrrice Calc C5 File Text File Matrix Printer Image File Saving in FPX format FPX format is FastReport s native format The advantages of this format are as follows e saving the report without losing the quality Opening an already saved file you can do all operations with it like print export editing e compact format based on XML compressed with the help of ZIP e when needed the report file can be unpacked by any archiver that supports the ZIP format and corrected manually in any text editor The only thing lacking with the format is that to view it you need to have FastReport Net In order to save in the FPX format press the Save button in the preview window and choose the Prepared report file type For opening already saved files press the Open button 290 Preview print export Export to Adobe Acrobat PDF PDF Portable Document Format is a platform independent format of electronic documents created by Adobe Systems The free Acrobat Reader package is used for viewing This format is rather flexible it allows the inclusion of necessary fonts vector and bitmap images it allows transferring and storage of documents intended for viewing and further printing Export method is a layered one When exporting to Excel there will be a dialogue window for setting parameters of the
79. L i Pe ear oe ee PEED EIDE Prepared in 16 ms UW E ato 0 Report outline Statusbar zoom control On the toolbar you can find the following buttons 286 Button S E dah Print el Save S DO Allie amp WwW A 1iof4 P pil Close Description Print the report Open the prepared report file in FPX format Save the report in one of the supported formats Preview print export H R amp A j ails p bl Send the report by email Text search in the report Shows or hides report outline Page settings Edit current report page Watermark settings Navigate to the first page Navigate to the previous page Navigate to the indicated page Enter the page number and press Enter Navigate to the next page Navigate to the last page You can use the following keyboard control Key Ctrl P Ctrl F Arrows PageUp PageDown Home End ESC Editing the report For editing a page of a prepared report click the cl button in the preview window During Description Print the report Text search Scroll the preview Page up down Navigate to the first page Navigate to the last page Close the preview window this the current page will loaded in the report designer where you can do whatever you want with it Preview print export 287 FastReport Untitled frx EMPLOY Anne Dodsworth oO m Birth date o 01
80. R Example ToWordsRu 1024 25 EUR OnHa THCHYUa gBaguaTb ueTHpe eBpO 25 eEBPOLLEHTOB Function Parameters Return value ToWordsRu object value Sepang bool male SEBUT Ome EAEE OENE string many Converts the specified integer value to words in russian The male parameter indicates the gender of the name The one two and five parameters contain a form of the name used with 1 2 and 5 numbers Example the ctrpaHuua word is of female gender male false ToWordsRu 122 false ctTpaHuua cTpaHuub cTpaHnny CTO QBaaquatTb OBE CTpaHUuB the muct word is of male gender male true TOWOLGSRUCI 22 true iunet sucta IAC roOB CTO DBavguatTb OBa nucta Program Flow Choose Function Parameters Return value Choose double index object params object choice Returns an element of the choice array with the index specified in the index parameter The first array element has 1 index Example Choose 2 one two three two 232 Data lif Function Parameters Return value dl gee bool expression object oTe Ce ErucPart object falsePart Returns the truePart value if the expression is true Otherwise returns the falsePart value Example IIf 2 gt 5 true false false Switch Function Parameters Return value POWERCON params object expressions object The argument supplied to expressions consists of paired expres
81. This value is reset at the start of a new group int Absolute number of data row This value is never AbsRow bsRow reset at the start of a new group 246 Expressions Every variable has a definite data type And on this depends how it will be used in the expression Here is an example of an expression where date is being used Date Year This expression returns the current year As Date variable has DateTime type we can refer to its Year property We can get the current month similarly Date Month FastReport converts reference to system variable into the following form for example the Date variable DateTime Report GetVariableValue Date Reference to total values In order to refer to a total value use its name TotalSales FastReport converts reference to totals into the following form Report GetTotalValue TotalSales As you can see the data type is not used here It is so because the total value is of FastReport Variant type It can be used directly in any expressions because it is automatically converted to any type For example TotalSales 0 2f Reference to report parameters In order to refer to report parameters you should use its name Parameter1 Parameters can be nested In this case you should use both parent and child parameter names in the following form ParentParameter ChildParameter Parameters have a definite data type It is set in the DataType propert
82. a column and the category picture Categories Picture data column Do the following e select the cell containing the employee s name and increase its size e add the Picture object to this cell e in order to show an employee s photo bind the Picture object to the following data column this can be done in the object editor Order Details Orders Employees Photo e select the cell containing the category name and increase its size e add the Picture object to this cell e in order to show a category picture bind the Picture object to the following data column this can be done in the object editor Order Details Products Categories Picture After that the matrix will looks as follows Report creation 137 Category Mame Employee Order Order Details UnitPrice Order Details Quantity decimalitd Order Details Discount When we run the report we will see the following Condiments Confections Employee 40 245 25 14 850 67 19 642 56 Example 8 Objects in cells Using objects inserted into matrix cells you can have various visual effects We will show in the following example how to draw a simple scale indicating employee s sales level The matrix will use the MatrixDemo data source To build a matrix add data columns in the following way 138 Report creation e add Year data column to the row header e add Name data column to the column header e add Re
83. a data source for the matrix the MatrixDemo table is used It presents the sales of the employees grouped by year and month Name Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Report creation Year Month ItemsSold Revenue 1999 2 1 1000 1999 11 1 1100 1999 12 1 1200 2000 1 1 1300 2000 2 2 1400 2001 2 2 1500 2001 3 2 1600 2002 1 2 1700 157 Andrew Fuller 2002 1 2 1800 Andrew Fuller 1999 10 2 1900 Andrew Fuller 1999 11 2 2000 Andrew Fuller 2000 2 2 2100 Janet Leverling 1999 10 3 3000 Janet Leverling 1999 11 3 3100 Janet Leverling 2000 3 3 3200 Steven Buchanan 2001 1 3 4000 Steven Buchanan 2001 2 4 4100 Steven Buchanan 2000 1 4 3999 Configure the matrix in the following way e put the MatrixDemo Year data column in the column header e put the MatrixDemo Name data column in the row header e put the MatrixDemo Revenue data column in the cell A prepared matrix will be as follows Employee 1999 000 O01 007 Total Andrew Fuller Janet Leverling Nancy Davolio Steven Buchanan 3 999 00 81100000 Total As seen the value of a cell is the sum of employee s sales for the whole year Let us create a detailed report which will be displayed when we click the cell In our case the detailed report can contain the sales of a selected employee for every month of a selected year How to connect a cell with data on which basis it was p
84. a simple report which prints a list of products We will use the Products table which can be found in the demo data base as our data source Assuming that you will be performing the actions written below in the demonstration program Demo exe from which the report designer can be called Example 1 Creating a report manually In this example we will create a report manually For this we will do the following ra e press the nl button on the toolbar and in the Add New Item window choose Blank report e in the Data menu choose the Choose Report Data item and check the Products data source Choose Report Data Select data sources and Fields that You want to use in the report E Categories E Customers Employees EJ Order Details EJ Orders E ve inline E Shippers JES Suppliers EJ MatrixDemo Categories BusinessObject Show aliases e switch to the Data service window if it is not on the screen it can be shown by choosing the Data Show Data Window menu item Expand the Data Sources item then the Products item 48 Fundamentals SI Data Sources esse Products ProductID ProductWame SupplierID Category ID QuantityPerLnit UnitPrice UnitsInStock UnitsOnOrder Reorderlevel Discontinued EAN 3 System Variables Totals T Parameters e drag the ProductName data column onto the Data band FastReport creates a Text object which is
85. ai Beverages Chang Beverages Data 203 Creating a relation In order to create a relation click the Actions button in the Data window and select the New relation item You will see the relation editor Edit Relation Parent table Child table Columns Parent LategoryID In the first place you need to choose the parent and the child tables After this in the lower part of the window you need to choose related data columns The tables can be related with the help of one or several data columns After the columns have been set close the relation editor by pressing the Ok button The relation that you ve created can be seen in the Data window if you choose the child data source and open a list of its columns Among the columns you will see the relationship with the parent source a Products 54 Categories CategoryID 2 jee Category Mape Parent source s data column can be inserted onto the report by using the drag amp drop method So if we choose the columns shown in the figure and drag it onto the report page we will get a Text object with the following contents Products Categories CategoryName Editing a relation In order to edit a relation open the list of columns of the child data source find the needed relation and click the Edit button located on the toolbar This will invoke the relation editor we have looked at earlier 204 Data System variables There is a list of
86. al data column name select the column containing country names usually this is the NAME column spatial data value Sales Country analytical data value Sales SalesT otal analytical data function Sum this function is used if you have several values per country The Zoom the polygon edit box allows zooming of the polygon with a given name so it occupies the whole Map object workspace For example to zoom Germany on the world map type Germany with quotes in this edit box for map layer type geodata from an application the Data tab looks like Data source Sales Appearance Filter fe Color scale Spatial data m Latitude Eales Latitude f Longitude Sales Longitude f Labels Label Sales CityName je Analytical data Value Sales SalesTotal fe Function Sum And the data required is spatial data latitude and longitude label eg a city name numeric value eg sales volume in this city For example a Sales data source may have this data Latitude Longitude CityName SalesTotal 48 13641 11 57753 Munchen 50000 50 94165 6 95505 K ln 36000 Set up the Data tab in the following way the data source Sales spatial data latitude Sales Latitude spatial data longitude Sales Longitude spatial data label Sales CityName analytical data value Sales SalesTotal analytical data function Sum this function is used if you
87. all the lines have been drawn click on the t button on the Objects toolbar An ordinary line differs from a diagonal line in that you can make it only vertical or horizontal Do not choose the Double line style for this object This style applies only to the object s border The Line object has the following properties Property Description Diagonal The property determines weather the line is diagonal An ordinary line can be turned into a diagonal one by enabling this property StartCap EndCap These properties allow to setup the line caps You can use one of the following cap styles ellipse rectangle diamond arrow Size of the cap can be set in the Width Height properties of the cap You can configure caps for each end of the line The Shape object The Shape object displays one of the following shapes rectangle rounded rectangle ellipse triangle diamond Fundamentals 39 The object is as follows In order to insert a shape into the report click the button on the Objects toolbar and choose the needed shape type The shape like any other report object has a fill and border Contrary to the Text object you cannot control each border line Also don t use the Double line style Instead of rectangular shape use the object s borders if possible The Shape object has the following properties Property Description Shape This property determines the type of shape Curve This pro
88. ameter button A new parameter will be created Data 197 Query Wizard Define parameters 7 Mame parami DataType arChar DeFaultyalue Expression Size Name The object s name The following parameter s properties should be set in the properties window Property Name DataType DefaultValue Expression Size Description Parameter name Here you need to indicate the same name which you use in the query text Some DBMS for example MS Access do not support named parameters In this case do not change this property Parameter data type Value which will be used if the Expression property is not specified or if it is impossible to calculate it for example when operating with the query in the report design mode Expression which returns parameter s value This expression will be processed when you run the report You can indicate any expression in this property see details in the Expressions chapter Parameter data size This property should be indicated if the parameter is of string data type If you set the parameter properties incorrectly you will get an error when turning to the last page of the wizard Passing a value to the parameter Parameters are often used to ask a value from the user Let us look at two ways to pass a value to the query parameter In the first way you pass a value programmatically Since there is no easy way to pass a value directly to the query paramet
89. ameters B Parameter Press F2 and give a parameter name then go to the Properties window and set the parameter s DataType property Parameters can be nested To create a nested parameter select a parent parameter right click it and choose the New parameter item in a context menu TE Parameters I TE ParentParameter BI ChildParameter You can refer to both parent parameter and nested one Nesting level is not limited Using parameters in a report You can refer to a parameter from an expression using square brackets Parameter name TO a nested parameter you need to refer using this method Parent parameter Child parameter Since a parameter has got a definite type it is given in the DataType property then with parameters you can perform those actions which are allowed for data type So string type parameters can be used in an expression the following way Data 239 StringParameter Substring 0 2 Let us see one example of using parameters Assuming we have a report which prints Employees table We want to modify the report to print information about an employee with an indicated number To do this we need to filter the data on the EmployeeID data column Create a parameter with EmployeeID name Indicate parameter s type Int32 as exactly this type has the EmployeeID data column To filter an employee with an indicated ID we need to enter Data band editor and indicate the following expression i
90. and is not connected to the source it gets printed once When you create a new report it already contains several empty bands including the Data band This band can also be added into the report from the Configure Bands window by choosing the Report Configure Bands menu item In order to connect a band to data double click it Choose data source in the editor window and click OK Edit DataBand Data source FA Em plo VEES Sort Filter Printing the text After you have connected the band to a data source you can place the Text object on the band which will display the information from a data column The fastest method to do this drag a data column from the Data window and drop it on the band Read more about the Text object in the The Text object chapter Sorting the data By default the Data band prints data in natural order Often it is needed to sort the data before printing For example a list of customers can be comfortably presented by sorting it in an alphabetical order Report creation 71 You can control sorting in the Data band editor In order to call the editor double click on a free space at the band Press to choose the Press to construct an data column expression Edit DataBand Data Source Ascending O Descending Sort Filter Ascending Descending Then by Bens Descending As a sort criteria you can use either a data column or an e
91. arcode It determines the size of barcode element in screen pixels As a rule the element s height should be greater than the element width by 3 times or more Encoding This property is specific to the Datamatrix barcode It determines the Datamatrix data encoding PixelSize This property is specific to the Datamatrix barcode It determines the size of barcode element in pixels SymbolSize This property is specific to the Datamatrix barcode It determines the size of barcode symbol The CheckBox object The object displays the checkbox in the report It looks as follows The object can display two states Checked and Unchecked Use the following ways to handle the object s state e set the state in the Checked property e bind the object to a data column using the DataColumn property e set the expression that returns the true or false in the Expression property The CheckBox object has the following properties Property Description CheckedSymbol These properties determine the symbol that is shown in the UncheckedSymbol object depending on the object s state CheckColor This property determines the color of the check symbol CheckWidthRatio Use this property to set the check width ratio The width of the check symbol depends on the size of the object You can Fundamentals 43 use values in the 0 2 2 range HidelIfUnchecked This property allows to hide the object if it is unchecked Checked This property
92. ase report This object will be deleted from the inherited report as well e add the object into the base report This object will appear automatically in the inherited report e change the size location text appearance of the object All changes will be reflected in the inherited report in case where this object was not changed in the inherited report The last point requires some explanations Let us look at two examples of using inheritance In the first example we will do the following 164 Report creation create a base report which contains the Texti object create an inherited report and just save it without changing anything open the base report and move the Text1 object open the inherited report and we will see that the Text1 object is moved as well In the second example we will do the following create a base report which contains the Texti object create an inherited report in the inherited report move the Text1 object to a new position and save the report open the base report and move the Texti object to different position open the inherited report and we will see that the Text1 object is not moved It happens because we have changed the object in the inherited report This change was saved in the inherited report file Now if we change the original object in the base report it will be ignored in the inherited report In this case the new object s location will be ignored All other changes such as text co
93. band is stretched if it can 7 the AfterLayout band event is fired 8 if the band cannot fit on a free space on the page a new page is formed 9 the band and all its objects are displayed on a prepared report page 10 the AfterPrint band event is fired 11 the AfterPrint event of all the band objects is fired Ou BR WN Be Printing of the band row occurs as long as there is data in the source After this the formation of the report in our case ends The FinishPage event of a page is fired and finally the FinishReport event of the Report object So by using events of different objects you can control every step of report formation The key to correct use of events full understanding of the band printing process expound in the eleven steps above So a lot of operations can be done by using only the BeforePrint band any change done to the object will also be displayed But in this event it is not possible to analyze on which page will the band be printed if it stretches because the height of the band will be calculated on step 6 This can be done with the help of the AfterLayout event in step 7 or AfterPrint in step 10 but in the latter case the band is already printed and operations with objects do not give out anything In one word you must clearly state at what moment each event is fired and use those which correspond with the given task Using Net objects In a script you can use any Net objects which are defi
94. bject on bands which will be printed on every new page Page header Page footer etc The matrix in this case will be created every time when the band will be printed which will lead to stack overflow Most examples will be using the MatrixDemo table which is bundled with the FastReport package This table contains the following data Name Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Nancy Davolio Andrew Fuller Andrew Fuller Andrew Fuller Andrew Fuller Janet Leverling Janet Leverling Janet Leverling Steven Buchanan Steven Buchanan Steven Buchanan Report creation Year 1999 1999 1999 2000 2000 2001 2001 2002 2002 1999 1999 2000 1999 1999 2000 2001 2001 2000 Month 2 11 12 w N N 10 11 10 11 ItemsSold Revenue 1 1 e gt A W U WD U N N N N N N N N 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 3000 3100 3200 4000 4100 3999 129 Example 1 Simple matrix The matrix will contain one value in a row and a column as well as one data cell In order to build a matrix you need to add MatrixDemo data columns in the following way e add Year data column to the row header e add Name data column to the column header e add Revenue data column to the matrix cell After that the matrix will look as follows Year Name Total Year Revenue Total Let us improve the matri
95. blem when series is filled with data with several identical X values For example the MatrixDemo table which is used to demonstrate charts has the following data Name Year Month ItemsSold Revenue Andrew Fuller 2002 1 2 1800 Andrew Fuller 1999 10 2 1900 Andrew Fuller 1999 11 2 2000 Andrew Fuller 2000 2 2 2100 Janet Leverling 1999 10 3 3000 Janet Leverling 1999 11 3 3100 Janet Leverling 2000 3 3 3200 If we try to build a chart based on this data for example employee s sales set X value to Name column Y value to ItemsSold column we will get the following wrong result Ttems sold Nancy Davolio Andrew Fuller Janet Leverling In this situation we need to group the same employees into one value To do this select the series in the series list and switch to the Data processing tab Select the group type X value and choose Sum as group function Data processing Group by Appearance roun interva Group function Sum we Fill amp border As a result all identical employees will be grouped into one value their sales will be Summarized You will see the following result Report creation 173 Items sold Collecting the data Andrew Fuller JanetLeverling Nancy Davolio Steven Buchanan This instrument for data processing allows to collect several series value into one value You can choose one of the following algorithms Algorithm TopN BottomN Less than value Less than percent
96. circular financial pyramidal ranges The object looks like this Fundamentals 45 Items sold per year Zr My Series1 1 9 0 5 You can learn more about this object in the Report creation chapter The Chart object has the following properties Property Description Chart Reference to Microsoft Chart object AlignXValues This property allows to align X values in different chart series by inserting empty values It is used if the chart contains two series or more AutoSeriesColumn These properties allows to set up automatically created series AutoSeriesColor Read more about this in the Report creation chapter AutoSeriesSortOrder DataSource The property allows connecting the chart to the data source Filter This property contains expression for data filtering which will be applicable to data source of the chart see DataSource property The Zip Code object The Zip Code object allows to print a zip code on envelopes It may display numeric characters 0 9 The object is as follows 122456 You can connect an object to data by using one of the following methods e set the zipcode data in the Text property e bind the object to a data column using the DataColumn property e set the expression that returns the zipcode data in the Expression property The Zip Code object has the following properties 46 Fundamentals Property SegmentCount SegmentWidth SegmentHeight Spacing ShowGrid
97. codeObject Displays a barcode A Chec kBox Displays a checkbox which can have two CheckBoxObject states Enabled or Disabled Table Displays a table containing rows columns and TableObject cells Matrix Displays a matrix also known as Cross MatrixObject tab Chart mh MSChartObject Displays a chart Zip Code l 42 ZipCodeObject Displays a zip code E Cellular Text Displays each character of a text in its a CellularT extObject individual cell An object can be used to display an information Text object or to improve the report appearance Picture Line Shape objects Complex objects like Table and Matrix can contain other simple objects Common object properties All report objects are inherited from one basic class ReportComponentBase and have got certain set of common properties Before studying each object we will look at these properties You can change the value of properties with the help of the Properties window Some properties can be changed using the object s context menu or toolbars for example border and fill Fundamentals 27 Property Left Top Width Height Anchor Dock Border Fill CanGrow CanShrink ShiftMode Grow ToBottom CanBreak PrintOn Cursor Visible Printable Hy perlink Bookmark 28 Description A report object as a rule is a rectangle It has coordinates properties Left Top and size propertie
98. connect each series to data columns 2 Use fixed values for each series 3 Fill the object with data using the script To connect the chart to a data source follow these steps e select the Chart object in the series list e switch to the Data tab e choose the data source Data J d O P TEO O a O a es p sess e if necessary set the data filter expression This filter will be applied to all chart series e select the series in the series list Report creation 171 e switch to the Data tab e choose data columns for each series value Depending on series type it may have two or more values Most series types have two values X value and Y value e if necessary set the data filter expression This filter will be applied to current series only e in the Color control you may indicate a data column which returns a color value You may also provide list of values for the series In this case the data connection is not needed To do this select a series in the series list and switch to the Values tab Fill the table with values Sorting the data By default the chart object displays data in natural order You can change the sort order to do this select the series from the series list and switch to the Data processing tab You can choose one of the sort modes do not sort sort by X value and sort by Y value 172 Report creation Grouping the data Sometimes we face a pro
99. connected to this column and a header for it e we will create the UnitPrice data column by using another method For this press the Text button on the Objects toolbar e leave the mouse and drag its pointer onto the Data band you will see that FastReport offers to insert an object Choose the needed position and click the mouse to insert the object e place the mouse pointer on the object and click the small button in the right corner of the object You will see a list of data columns Choose the UnitPrice item from the list F None i sh i ProductIC FroductMame Supplier IC Category IC A QuantityPerLnit UnitPrice UnitsInStock UnitsOnOrder ReorderLevel Discontinued EAM 15 e fel fe gt K E fe E Fundamentals 49 e create the Text object header for the UnitPrice column Place in on the Page Header band Double click the object and write the text Unit Price e create the Text object report title Place it on the Report Title band and write the text PRODUCTS e set Bold as font style for all objects that are placed on the Page Header and Report Title B bands For this select objects by pressing Shift and press the button on the Text toolbar After this the report will be looking like this r q Report Title 2 PRODUCTS L ProductName Unit Price Page Header Products UnitPrice a a a Cn r r L L r r L L Products Product arme
100. controls the state of the object DataColumn The data column which this object is bound to The type of column should be either bool or int Expression The expression that returns the true or false The Table object The Table object is made up of rows columns and cells It is a simplified analog of Microsoft Excel table It looks like this You can learn more about this object in the Creating reports chapter The Table object has the following properties Property Description ColumnCount Use this property to quickly set the number of columns If columns in a table are few they get added and when they are more they get deleted RowCount Use this property to quickly set the number of rows If rows ina table are few they get added and when they are more they get deleted FixedColumns The property determines how many columns in the table are fixed Fixed columns form the table header Printing of the header is controlled by the RepeatHeaders property FixedRows The property determines how many rows in the table are fixed Fixed rows form the table header Printing of the header is controlled by the RepeatHeaders property RepeatHeaders The property allows printing the table header on every new page This property works only for tables which are formed dynamically 44 Fundamentals The Matrix object The Matrix object is like the Table object made up of rows columns and cells At the same time it
101. d decimal Returns the largest integer less than or equal to d Example 208 Data Floor 1 1 Log Function Parameters Log double d Returns the logarithm of a specified number d Example LOG 24 7 L628 aA Maximum Function Parameters Maximum delle weal SIGH val Maximum EON G A Ikers iep geno Maximum tiloataeve lIs float valz Maximum double vall double val2 Maximum decimal vall decimal val2 Returns the larger of vali val2 Example Maximum 1 2 2 Minimum Function Parameters Minimum agency Miller tat val Minimum Ios meaner Ong iVar Minimum Eloot era nir tloa yal Minimum double vall double val2 Data Return value double Return value TUTE IEG leg eye double decimal Return value ign Pang float double 209 Minimum decimal vall decimal decimal valz Returns the smaller of vali val2 Example Minimum 1 2 1 Round Function Parameters Return value Round double d double Round decimal d decimal Rounds d to the nearest integer Example Round 1 47 1 Function Parameters Return value Round lousy Oley rot double TGS IAC SNC EES Round decimal d decimal UO Glal milagis Rounds d to a precision specified in the digits parameter Example Rownd L476 2 12 48 Sin Function Parameters Return value SLA double d double Returns the sine of the specified angle d The angle must be in radians Multiply by Math PI
102. d in the expression It is enclosed in square brackets Reference to data sources For reference to data source columns the following format is used DataSource Column Source name is separated from column name by a period for example Employees FirstName Source name can be compound in case if we refer to a data source by using a relation See more details in the Data section For example this is how you can refer to a related data source column Products Categories CategoryName Let us look at the following example of using columns in an expression mon Employees FirstName Employees LastName Expressions 245 Here it should be noted that every column has a definite data type which is set in the DataType property you can see it in the Properties window if to choose data column in the Data window beforehand How a column can be used in an expression depends on its type For instance in above mentioned example both columns first name and last name have got a string type and that is why they can be used in such a way In the following example we will try to use Employees Age column of numeric type which will lead to an error Employees FirstName Employees Age The error occurs because you never mix strings with numbers For this you need to convert the number into a string Employees FirstName Employees Age ToString In this case we refer to the Employees Age column as if
103. dd a dialogue into the report and drag Products UnitPrice data column into it After that we will correct the label text Now in the same way add one more Products UnitPrice column and correct its header Dialogue forms 281 Unit price From That is all we need to do the rest of the work FastReport has done connected the controls to the data column and set up their FilterOperation properties The first control has got FilterOperation GreaterT hanOrEqual the second LessThanOrEqual Run the report and indicate the values for example from 20 up to 30 When pressing the OK button a report will be built It contains products having values in the indicated range Product name Chef Anton s Cajun Seasoning Chef Anton s Gumbo Mix Flgitemysost Grandma s Boysenberry Spread Gravad lax Gustaf s kn ckebr d Louisiana Fiery Hot Pepper Sauce Maxilaku Mord Osk Matjeshering Pate chinois Queso Cabrales Sirop d rable Tofu Uncle Bob s Organic Dried Pears Example 8 Filtering by related data column UnitPrice 2 00 21 35 21 50 25 00 6 00 1 00 1 05 0 00 25 09 24 00 1 00 25 50 25 25 30 00 In this example we will use a column froma related data source to perform data filtering We will look at a Simple list report type which prints products list Category name is printed beside each product This is done with the help of the relation Products Categories CategoryName The report will be
104. der element select it and right click to display its context menu Hyperlink Totals start New Page Descending Do not sort Suppress Totals Delete By default data in the matrix header is sorted in ascending order You can change the order of sorting by selecting the Sort item Ordinarily every item in the matrix header has a total this is a cell with a Total text You can delete the total selecting it and pressing the Delete key In order to enable total again select an element to which it belongs and choose the Total item in its context menu The Start New Page menu item tells the matrix to insert page breaks after printing each header value For example if you enable page breaks for the Year item as shown in the picture above every year value will be printed on its own page The Suppress Totals item allows to suppress totals in case when the group on which the total value is calculated contains only one value Configuring cells For a matrix cell you can choose a function which will be used when calculating the total A list of functions which can be used is given below Function Description None Cell value is not processed Sum Returns the sum of the values in the matrix cell Min Returns the minimum value Max Returns the maximum value Average Returns the average value Count Returns number of nonempty values By default the Sum function is used You can
105. dify the object s appearance so it will look like a clickable link After this enable the Modify the object s appearance checkbox in order to apply some link attributes blue text color underlining and a hand like cursor to the object Run the report and click on the object The web browser window opens and you will move to the FastReport home page Report creation 151 Example 2 Building a detailed report In this example we will build a report that displays the category list When clicking on the category name a detailed report that contains the list of products in the given category will be shown You need to do the following first create a detailed report define the report parameter which identifies a category set up data filtration on this parameter create the main report in the main report configure the hyperlink such that the detailed report can be run with the parameter set to the chosen category Firstly we will create a detailed report which prints a list of products For this create a new report and choose the Products table as a data source Place the objects in the following way Report Title Page Header Product Name EL l Products Product ame L Quantity Per Unit L Froducts QuantityPe oe od Sa j UnitPrice m J L Froducts UnitPric L 4 J 1t Create the parameter which will be used
106. dll System Data dll System sml dll For example if you want to use a function in your report which was declared in your application add application assembly exe or dll in a report assemblies list After that you can call the function by using namespace of your application For example if the following function is defined in application namespace Demo i public static clase Myrunctlons public static string Funcl return Hello You can use it in your report in the following way 244 Expressions Demo MyFunctions Func1 If you add the using Demo line at the top of the report s script it will allows you to shorten the syntax MyFunctions Func1 To refer to the function or variable that was defined in a script just use its name myPrivateVariableThatIHaveDeclaredInScript MyScriptFunction You can use in an expression only those functions which return a value Reference to data elements Apart from standard language elements you can use the following report elements in expressions data source columns system variables total values report parameters All these elements are contained in the Data window See more details in the Data chapter Any of these elements can be used in an expression by including it in square brackets For example Page 1 This expression returns next printed page number A system variable Page which returns Current report page number is use
107. e Page Creating a SQL query Data wizard allows quickly choosing tables contained in a data base Creation of SQL query requires additional work For this press the Add SQL query button in the second step of the wizard Data 195 Data Wizard Choose tables Which tables you want in your report E HJE cross 1E long table Add SQL Lenan You will see the query wizard window Query wizard has four pages Use the Next and Back buttons to switch between the pages In the first step you need to set the name of a query This name will appear in the Data window Enter any unique name and press the Next button Query Wizard Enter a SQL statement What data should return the query Type your SOL statement or use the Query Builder to construct it select From cross Query Builder In the second step you have to enter a query in SQL language Use the language dialect which is supported by your MSDB You can use the query builder for visual query creation To do this press the Query Builder button The query builder will be described in details later After you have entered the query text press the Next button In the third step you can define the query parameters It is required if your query has parameters We will consider parameters later in this chapter 196 Data On the last step of the wizard you can set up the columns which were returned by the query Query Wizard Define c
108. e This means that when the main report will be built this page will be skipped Custom link Using this type of link you can define own reaction to the clicking of the mouse For this use the Click event handler of the object To do this e select the object and open the Properties window e Click the F button to show the object s events e double click on the Click event FastReport switches to the Code window and creates an empty event handler In the handler s code do everything what you need You most likely will need a link to the object which the handler calls and a hyperlink s value Use the handler s parameter sender 148 Report creation private void Text Click ob ect sender EventArgs e sender this is the object which was clicked In order to receive the value of the hyperlink you need to cast the sender to ReportComponentBase type object hyperlinkValue sender as ReportComponentBase Hyperlink Value MessageBox Show Hyperlink value hyperlinkValue ToString Report outline Report outline also Known as the document map is a TreeView control displayed in the preview window Ge Print a B sae 6 d DO F amp M 4 l of24 p H Alfreds Futterkiste i E Ana Trujillo Emparedados y hef Antonio Moreno aqueri S h OrderID OrderDat ee 10365 28 12 H 10759 fais Le 10926 10507 Antonio Moreno Taqueria 10535 pl i Around the Horn 10573 p Berglunds snabbk
109. e TitleCase Seis igo IS SASE Converts the specified string to titlecase Example TitleCase john smith John Smith Trim Function Parameters Return value WEAN SCENO S SE Removes all occurrences of white space characters from the beginning and end of the s string Data 215 Example Trimi ABC ABC UpperCase Function Parameters Return value UpperCase Sieh liens SE Converts all characters of s to upper case and returns a result Example UpperCase abc ABC Date amp Time AddDays Function Parameters Return value AddDays DateTime date DateTime double value Adds the specified number of days value to the date date and returns a new date Example AddDays 7 29 2009 1 7 30 2009 AddHours Function Parameters Return value AddHours DateTime date DateTime double value Adds the specified number of hours value to the date date and returns a new date Example AddHours 7 29 2009 1 30 1 7 29 2009 2 30 216 Data AddMinutes Function Parameters Return value AddMinutes DateTime date DateTime double value Adds the specified number of minutes value to the date date and returns a new date Example AddMinutes 41 7297 2009 12308 DE 772972009 14314 AddMonths Function Parameters Return value AddMonths DateTime date DateTime denies value Adds the specified number of months value to the date date and returns a new date Example
110. e group allows choosing one of the printing modes Mode Description The printer prints on a paper indicated in the report One BE gt Default report page corresponds with one printed sheet E eat h Use this mode if you need to print A3 report on a A4 format d paper One report page will produce two printed sheets When using this mode you have to choose the paper format from the Print on sheet list Preview print export 289 Use this mode if you need to print A4 report having on a A3 a gt a Scale format paper On one printing sheet you can print 1 2 4 or 8 report pages When using this mode you need to choose the format of the paper on which you want to print from the Printing on sheet list and also indicate the number of pages in the Pages on sheet list After pressing the Print button printing of the report will start If the Print to file flag is chosen then the name of the file will be requested and the report will be saved in that file file with a PRN extension Exporting the report FastReport allows exporting the built report into different formats At the moment export to 11 formats is supported PDF RTF HTML MHT Excel XML Excel 2007 PowerPoint 2007 OpenOffice Calc CSV TXT image file For choosing export press the Save button in the preview window and choose the export Prepared report A Adobe Acrobat W Rich Text file HTML file M
111. e a matrix element Then set the following expression for the cell Order Details UnitPrice Order Details Quantity decimal 1 Order Details Discount Why did we indicate such a long data column as a name of an employee though we could get a name from the Employees FirstName We did that because the matrix is connected to Order Details data source Using relations between this data source and other tables it is easy to refer to its columns more details about relations can be read in the Data chapter If we refer directly to the Employees FirstName data column we will get a name of the first employee in a table Set up the matrix appearance After that it will look as the follows Employee CakegoryNarne order Details Orders Emplo veges FirstName Order Details Orders Emplo yees Lasthame When we run the report we will see quite a big matrix which occupies 2 sheets 136 Report creation IeVeY ages Condiments Confections Dairy Products Anne Dodsworth Janet Leverling Laura Callahan Margaret Peacock Michael Suyama Nancy Davoli Robert King Steven Buchanan Example 7 Pictures in cells Matrix cells are inherited from the Text object and can display text data If it is not enough you can put any object into the cell Let us see how to display a picture in a matrix For this we will take Example 6 as a basis Let s add a photo of an employee Employees Photo dat
112. e given case as a link value You can indicate the page number by using two methods e indicate the number directly for example 1 e indicate an expression which returns the page number This expression will be calculated when you run the report Link to a bookmark By using this type of link you can navigate to a bookmark defined in another report object For those who know the HTML language it is enough to say that a bookmark acts like an anchor A bookmark has got a name and a definite position in a prepared report page number and position on the page When moving to a bookmark by its name you navigate onto the indicated position In order to use this link type you first need to define the bookmark In order to do this select the object where you want to move when you click on the link Almost all report objects have the Bookmark property Changing this property can be done with the help of the Properties window The Bookmark contains an expression which you can use in the following way e indicate the bookmark name as a string My Bookmark e indicate an expression which returns the name of the bookmark For example you can use a data column as an expression The value of the expression will be calculated when the report is run After the bookmark has been defined you can indicate its name in the hyperlink configurations window This can be done by using two methods e indicate the name of the bookmark d
113. e object s appearance will be changed according the style settings When you change the style settings the object with that style will change automatically Data formatting To print a textual data in a report the Text object is used It applies the default formatting to all data that comes from data source For example the data source columns of type DateTime will be printed in the following way it depends on your system s regional settings 11 10 2008 18 04 52 If you need to print the date part only you have to set up the data formatting To do this right click the Text object to show its context menu In the menu choose the Format item You will see the format editor window 64 Report creation Select Format General 11 30 2007 Mumber Friday Movember 30 2007 1 30 PM Friday Movember 30 2007 1 30 00 PM 11 50 07 Currency 11 30 2007 November 2007 Time Percent Boolean Sample Friday November 30 2007 Custom You may choose one of the available formatting types or set up own formatting string To do this select the Custom formatting If the Text object contains several data columns or expressions you may choose appropriate format for each of them To do this select the expression in the top of the window then choose the format Select Format Expression Employees FirstName General Mumber Currency Date Time Percent Boolean Custom Report creation 65 You may also format t
114. e the KeepWithData property The following bands have got this property report header report footer data header data footer group header group footer This property allows to keep header footer with at least one data row Keep WwithData False Keep WwithData true In order to keep a band and its child band together enable the KeepChild property Printing empty data rows Often enough when printing on pre printed forms a certain amount of data rows is supposed to be printed If the actual data is less than needed amount of rows then empty rows need to be printed This can be done with the help of the Child band by attaching it to the Data band Report creation 77 The Child band has got a CompleteTONRows property If this property is set to value greater than O the band will be used for additional data rows up to the indicated amount For example we need to print 15 rows but there are only 8 rows in the data source In this case the Child band will be printed 7 times Data Categories Row Categories Category Name ci Child1 Hyperlink Can Grow Can Shrink Can Break Fill Unused Space Complete upto N data rows 19 4 Start Mew Page Prink Qn Bottom Delete The prepared report will look like this If the data source has more rows than indicated in the CompleteToONRows property then an empty row will not be printed Another way to print an emp
115. e to set all objects height to the maximum height of the band Anchor property Every report object has this property It determines how the object will be changing its position and or its size when the container on which it is laying will be changing its size By using Anchor it can be done in such a way that the object expands or moves synchronously with its container The container being referred to in many cases will be the band But this is not a must this can also be the Table or Matrix objects Report creation 59 The Anchor property can have one of the following values and also any combination of them Value Left Top Right Bottom Description Anchors the left edge of the object When the container s size will be changing the object will not be moving left right Anchors the top edge of the object When the container s height will be changing the object will not be moving up down Anchors the right edge of the object When the container s width will be changing the distance between the right edge of the object and the container will be constant If the left edge of the container is anchored as well then the object will be growing and Shrinking synchronously with container Anchors the bottom edge of the object When the container s height will be changing the distance between the bottom edge of the object and the container will be constant If the top edge of the object is anchored as we
116. e with products When you choose a category in the first list you will see in the second list the products in a chosen category 274 Dialogue forms Categor yName Meat Poultry s ProductName Mishi Kobe Niky l the products list will Alice Mutton be refreshed Th ringer Rostbratwurst automatically Perth Pasties Tourti re Pate chinois when you choose a category from this list a To create a cascading list you need to use two data sources with master detail relation between them read more about data sources and relations in the Data chapter Attach the master list to a column in the master data source attach the detail list to a column in the detail data source Also set the master list s DetailControl property to the detail list Controlling the filtering from code Even if automatic filtering is enough for many cases you have the possibility of managing it manually For this the following methods and properties are used The AutoFill property controls the filling of controls with data It is used by controls which can show a list of values for example the ListBoxControl Before showing a dialogue FastReport fills such controls with data By default the property is set to true If it is disabled the control will not be filled and you must do it yourself by calling the FillData method ListBoxl FillData The AutoFilter property controls the data filtering It is used by all controls After the dia
117. ear DateTime date INANE Gets the day of the year 1 365 represented by the specified date Example DayOfYear 7 29 2009 210 DaysInMonth Function Parameters Return value DaysInMonth int year Ligue KACON E Returns the number of days in the specified month and year Example Days InMontht 2009 Th S 31 Hour Function Parameters Return value Hour DateTime date LAOL Gets the hour component 0 23 represented by the specified date Example Hour 7 29 2009 1 30 1 Minute Function Parameters Return value Minute DateTime date LAL Gets the minute component 0 59 represented by the specified date Example Minute 7 29 2009 1 30 30 Data 219 Month Function Parameters Return value Month DateTime date LAL Gets the month component 1 12 represented by the specified date Example Month 7 29 2009 7 MonthName Function Parameters Return value MonthName TOE MO is A SELEG Gets the localized name of the specified month 1 12 Example MonthName 1 January Second Function Parameters Return value Second DateTime date int Gets the seconds component 0 59 represented by the specified date Example Second 772972009 1230 057 5 Year Function Parameters Return value Year DateTime date LAL Gets the year component represented by the specified date Example Year 7 29 2009 2009 220 Data Formatting Format Function Parameters Return value Format S
118. ected columns 42 ProductID A ProductName Supplier ID 2 Category ID LA QuantityPerUnit 42 ReorderLevel Discontinued Cancel e the rest of the steps can be skipped click the Next button e on the last step of the wizard choose Blue style and click the Finish button 52 Fundamentals Standard Report Wizard Select style Select the report style CUSTOMERS AX rocks F ullike 4rea rug Esrqanbekes y bok Arto Pr ee Ariane Lh Hem Eaorgiureks sri Ekner Cas Chiba isco Earache patria id ka ania Gorge Perii Ciir Chara Conia Freer FastReport will create the following report r 71 Report Title Products Page Header Products ProductName Products UnitPrice Page Footer To run a report click the button on a toolbar The report will be built and shown in the preview window Products ProductName 0 UnitPrice Chal 18 Chang 19 Aniseed Syrup 10 Chef Anton s Cajun Seasoning Ze Chef Anton s Gumbo Mix 2135 Grandma s Boysenberry Spread 25 Uncle Bob s Organic Dried Pears a Northwoods Cranberry Sauce 40 Mishi Kobe Niku gr Ikura a Chuieewg Cahrgles 0 o a ee tn an E Fundamentals 53 Report creation Report creation In this chapter we will look at the methods of creating common types of reports In order to create any report as a rule you need to do the following 1 Choose or create data which will be used in the report 2 Create the repo
119. ed One row of the master source can correspond with several rows of the detail source More details on relations can be found in the Data chapter It is necessary to place a band in a report in such a way that the master band contains the detail band inside it This can be done in the Configure bands window which can be called in the Report Configure Bands menu Let us look at the creation of a master detail report froma scratch For this we will run the report designer and create a new empty report It already contains one Data band ne TG I i i Z oi 3 Report Title Page Header Page Footer In order to add a detail data band call the Configure Bands window This can be done by pressing the Configure bands button shown in the figure or by choosing the Report Configure Bands menu item In the configurations window the band structure is displayed Contigure Bands JEI Report Title Marre Datal Page Header Bookmark H Border Border F Page Aaater CanBreak False CanGgrow False CanShrink False Columns BandColumns Cursor Default DataSource EvenSstyle EvenstylePriority UseFill Fill Solid Filter Li iak be Name The object s name Report creation 83 Select the Data band as shown in the figure and right click the mouse in order to show the context menu or press the Add button in the lower part of the window In the
120. ed its own total values If we uncheck the Reset after print checkbox the total will not be reset after printing This is what is called running total If you need to print two types of totals at the same time ordinary totals and running totals create one more total with similar settings and uncheck the Reset after print flag Page totals In order create a total which will be printed on the page footer you will have the indicate page footer in the Print on the band field Printing the total in the header Usually you will print total values on the footer bands such as data footer group footer etc It s a natural printing order because when you print the total its value is properly calculated and is ready to use However in some cases you would need the total to be printed on the header for example on the group header If you try to do this you will see a zero value At this moment when you print a total it is not calculated yet To solve this problem FastReport has a feature called delayed print The Text object has a property called ProcessAt which can have one of the following values Value Description Default The default printing mode This is the default value ReportFinished The object s value will be calculated at the end of the report ReportPageFini The object s value will be calculated when all bands in the page will be shed finished PageFinished The object s value will be calculated at the end
121. eing saved to Google Drive Before saving a report to Google Drive an application must be created in your Google Drive account Do this by going to https code google com apis console this page has the license agreement and leads to the Project Settings page Go to the Services tab and activate the Drive API Go to the API Access tab and click Create an OAuth 2 0 client ID In the Branding Information section enter the name of the application and click Next In Client ID Settings select the following Installed application for Application type Other for Installed application type 304 Preview print export Click Create Client ID As a result the next page shows the Client ID and Client secret You can now go to the FastReport NET preview and export the file to Google Drive by pressing the Save button and selecting GoogleDrive When exporting to a Dropbox for the first time the Client Information window will be displayed Client Info es Client ID Client Secret Enter the Client ID and Client Secret obtained above After clicking the OK button FastReport NET saves these values and uses them again the next time The Save to Google Drive window has two tabs File and Proxy N Save to Google Drive Prepared report Settings The File tab contains the following fields FTP Server ent
122. eld separator character e Codepage codepage used to encode the text in resulting file The Default codepage refers to Windows default codepage Note that Excel does not support unicode codepages e Data only enable this checkbox to export objects laying on Data band only Preview print export 299 Export to TXT TXT is a regular text file that can be opened in any text editor or printed to a dot matrix printer Export method tabular When exporting to TXT there will be a dialogue window for setting parameters of the output file Export to Text Matrix Printer Moel Sy Print Save of4 P P Close Options Page breaks _ Empty Lines Alice Mutton 39 00 _ Data only Aniseed syrup 10 00 Total products z Frames Codepage Scale Boston Crab Meat 16 40 Total products 1 Scale Scale Y Camembert Pierrot 34 00 Carnarvon Tigers be 50 Chal 16 00 Chang 19 00 Chartreuse werte 16 00 Chef Anton s Cajun Seasoning 22 00 Chet Anton s Gumbo Mix 21 35 Chocolade 1z T5 Cote de Blaye 263 50 Total products 9 Auto Scale Page width 77 Page height 58 Export parameters Page breaks enables page breaks in the resulting file Empty Lines enables empty lines in the resulting file Data only enable this checkbox to export objects laying on Data band only Frames type of object s borders Select None if you don t want to export borders Codepage codepage used to
123. ep it in mind when using such object s properties like Left Top Width and Height To convert pixels into centimeters and back use the constants defined in the Units class float heightInPixels Textl Height float heightInCM heightInPixels Units Centimeters Text Heighe Units Centimerers G 77 Secu 254 Script Report and Engine objects Apart from objects which are contained in the report there are two variables defined in the script Report and Engine The Report variable refers to the current report In the list below a list of the report object s methods is given Method object Calo string expression object GetColumnValue string complexName object GetColumnValueNullable string complexName Parameter GetParameter string complexName object GetParameterValue string complexName void SetParameterValue string complexName object value object GetVariableValue string complexName object GetTotalValue string name DataSourceBase GetDataSource string alias Description Calculates an expression and returns the value When calling this method the first time an expression gets compiled which needs some time Returns the value of the data column The name must be presented in the DataSource Column form If the column has got the null value it is converted into a value by default 0 empty string false Returns the value of the data column Contrary to the
124. eport GetDataSource Products Help on properties and methods of the DataSourceBase class can be received from the FastReport Net Class Reference help system As a rule this object is used in the script in the following way get a reference to the data source 258 Script DataSourceBase ds Report GetDataSource Products ff initialize it ds Init enum all rows while ds HasMoreRows get the data column value from the current row string productName string Report GetColumnValue Products Name jf Qdo Something With it yy go next data row ds Next Rererence to system variables For reference to system variables use the GetVariableValue method of the Report object DateTime date DateTime Report GetVariableValue Date A list of system variables can be seen in the Data window From it you can drag a variable into a script during this FastReport automatically creates a code for referring to the variable Reference to total values For reference to the total value use the GetTotalValue method of the Report object float sales Report GetTotalValue TotalSales A list of totals can be seen in the Data window From it you can drag a total into the script during this FastReport automatically creates a code for referring to the total Total value has got the FastReport Variant type It can be used directly in any expression because the FastReport Variant type is auto
125. er The height of the Righ gnt object will be equal to the height of the container BOROM The object is docked to the lower edge of the container The width of the object will be equal to the width of the container Fill The object occupies all the free space of the container This is not quite so if several objects have been docked at the same time The figure below Shows two objects the first one has been docked to the top edge of the container and the second to the left As seen the height of the second object is equal to height of the free space which remains after docking the first object The docking behavior depends on the object s creation order You can change the order in the context menu of an object To do this select either the Bring to front or Send to back menu items Report creation 61 Formatting In this section we will look at the following questions changing an object s appearance changing the format of printing values automatically changing the appearance of an object when fulfilling some kind of condition hide unnecessary values highlighting even data rows in different colors Border and fill Almost all report objects have the border and fill To work with these properties use the Border and Fill toolbar Controlling the border Fill Border line lines parameters The object s border consists of four lines Each line can have different width color and style The toolbar bu
126. er you need to use the report parameter which can be easily set via code You should do the following 198 Data e Create the report parameter we will discuss the report parameters later in this chapter Set the same DataType for the report parameter as it is used in the query parameter e In the Expression property of the query parameter refer to a report parameter for example MyReportParameter e Pass a value to the report parameter reportl SetParameterValue MyReportParameter 10 In the second way you use the dialogue forms to do this dialogue forms will be discussed later For example if you need to ask a string type value do the following e add a dialog into your report e put the TextBoxControl on it This control will be used to enter the string value e set up the parameter as follows Name param 1 DataType VarChar DefaultValue empty string Expression TextBoxl Text Size 255 Where TextBox1 is a control which contains a value entered by the user Editing a connection Data connection which was created with the help of the Data Wizard can be edited In order to do this choose the data connection in the Data window and press the Edit button on the toolbar You will see a data wizard window which we have looked at earlier In this window you can change the connection settings by pressing the Edit connection button The type of connection cannot be changed On the second page of the
127. er the URL address of the FTP server Username and Password enter your username and password File Type select the file format prepared report or one of the export formats from the drop down list If an export format is selected then the Settings button becomes available which opens the settings window for the chosen export format If a proxy server is used then the URL address port username and password of the proxy server are set on the Proxy tab Preview print export 305 Save to Google Drive Es Server Username Password When all settings have been made click the OK button to save the file to Google Drive Export to SkyDrive A prepared report can be saved to SkyDrive from the FastReport NET preview The report can be exported to one of the supported formats before being saved to SkyDrive Before saving a report to SkyDrive an application must be created in your SkyDrive account Do this by going to the SkyDrive home page and clicking Developers In the Development Center click My Apps and then click Create Application Enter the name of the application and select a language Read the Terms of Use and Privacy Statement and click I accept As a result the next page is the Settings page of the application which shows the Client ID and Client Secret Enter the redirection domain and click Save You can now go to the FastReport NET preview and export the file to SkyDrive
128. eractive i e you can click its elements to navigate to the corresponding page e in the preview window it will display the outline which is interactive as well 2 Preview rrit g save 9 4 9 50 A Da IM 4 1 ofS p gt D Close Outline S Table of Contents Beverages Condiments Confections Dairy Products Grains Cereals Meat Poultry Produce Seafood Table of contents Uri i x 2 i Prepared in 266 ms Memory used 264 Kb The report will use the Categories and Products tables In the TOC we will print the categories list The rest of report will print the categorized list of products Report template will be made up of two pages the first page will be used to print the TOC the second one is the main part of the report We will discuss the TOC firstly Create a new report and add Categories and Products data sources into it Connect the Data band to the Categories table and place the objects in the following way Report creation 161 Hyperlink to the bookmark with name Categories CategoryHame Report Ths Table of contents __ Categories CategoryName prne A Pisin aes poses QC Category page number Engine GetBookmarkPagel Categories CategoryName In order to make the TOC objects interactive configure its Hyperlink property Edit Hyperlink URL Specify a bookmark name page me Doo O or enter the expression thak returns a bookmark name Bookmark
129. erfect after being exported to any table based format Sending the report by email FastReport allows you to send a prepared report by email It may work in two modes Mode Description SMTP This is default mode To send an email you don t need any external programs MAPI You may turn on this mode programmatically To do this set Config EmailSettings UseMAPI true or if you use EnvironmentSettings component set its EnvironmentSettings EmailSettings USeMAPI property to true To send an email FastReport uses the default email client such as Outlook Express This client must support the MAPI protocol To send an email you need to specify a recipient s email address Also you need to specify the Subject and email body but this is not required At the bottom of the dialog select the format of your report it will be attached to the message Preview print export 309 Send E mail If you use the SMTP mode you need to set up an account It is necessary to do only once Once you have done it FastReport will save the parameters in the configuration file The parameters can be found on the Account tab All obligatory fields are marked by red asterisk Send E mail If your host server requires an authentication you need to fill in User name and Password fields as well 310 Preview print export
130. es separated by commas For example 1 5 5 12 Options VSI Pictures Sub Folder Navigator _ Single page Open after export Cancel Export parameters Wysiwyg the export result will be as close to the report as possible Pictures enables to export pictures Sub folder all extra files are saved in a separate folder called files Navigator creates a special navigator for navigating on pages Single page all pages will be saved in one file Appearance and size of the resulting file depends on the report template see the Recommendations on report development section Export to MHT web archive MHT short for MIME HTML is a web page archive format used to bind resources which are typically represented by external links such as images Flash animations Java applets audio files together with HTML code into a single file The content of an MHT file is encoded as ff it were an HTML e mail message using the MIME type multipart related Export method tabular When exporting into MHT a dialogue window will be offered for setting the parameters 294 Preview print export Export to MHT web archive Eg Page range all O Current page Enter page numbers andfor page ranges separated by commas For example 1 5 5 12 Options Wy Siang Pictures Open after export Export parameters e Wysiwyg the export result will be as close to the report as possible e Pictures
131. f every group when the value of the group condition changes It is printed at the end of every group This band can be connected to any band including another child band It is printed immediately after its parent Printed as a background on every report page Bands in designer A band in the designer appears in form of a rectangular area A band like many other report objects can have a border and fill by default they are disabled Apart from this a band displays a grid To set the grid mode go the View Options menu and choose Report page Grid can also be enabled or disabled in the View menu Fundamentals 21 You can set the band s height in three ways e place the mouse pointer at the bottom of the band The cursor shape will be changed to horizontal splitter and you can resize a band e drag the band handle on the left ruler e use Properties window to set the band s Height property The designer has two modes of displaying bands between which you can switch at any time In the first mode every band has got a header which contains the title of the band and useful information about it for example the name of the data source to which it is connected dle 6 a4 ot Fou 3 4 t 5 bt Bt oF Report Title Page Header In the second mode the band does not have a header Instead of that on the left side of the window the structure of the bands is displayed This mode helps to easily understand the
132. g the Repeat On Every Page property of the data header footer you can print these bands on every page of the report Breaking data and keeping it together In this section we will look at two modes of data printing Break and Keep together In an regular band printing mode FastReport checks if there is enough space on the current page to print a band If there is not the band is printed wholly on the next page If the CanBreak property of the band is enabled FastReport will try to print the part of the band on Report creation 75 the available space that is break it An attempt to break a band can be either successful or not It depends on the type of object which has been placed on the band and its settings The following objects can be broken Text e Rich Text e Table These objects have the CanBreak property as well If it is enabled then the object can be broken Non breakable objects are always displayed wholly there where they have enough place In the figure below how a band can be broken is shown CanBreak False CanBreak true Break algorithm does not always work correctly The artifacts can occur in a situation when there are several objects with different font size on a band The goal of band breaking is to save the space on the printed sheet Data keeping s goal is contrary display a set of bands wholly on one sheet In this case there will be a lot of unused Space on the s
133. g formatted has a digit in the position where the 0 appears in the format string then that digit is copied to the result string The position of the leftmost 0 before the decimal point and the rightmost 0 after the decimal point determines the range of digits that are always present in the result string Digit placeholder If the value being formatted has a digit in the position where the appears in the format string then that digit is copied to the result String Otherwise nothing is stored in that position in the result string Decimal point The first character in the format string determines the location of the decimal separator in the formatted value Thousand separator If the format string contains a character then the output will have thousand separators inserted between each group of three digits to the left of the decimal separator Percentage placeholder The presence of a character in a format string Causes a number to be multiplied by 100 before it is formatted Data Section separator The character is used to separate sections for positive negative and zero numbers in the format string Examples of use Formal 40 Format 4 04 Format oy Format C404 Format Yro S 0 00 1024 25 OUa Fa Oe 2 MDa ot FHO 00 S 0 00 ot HO 00 S 0 00 ot HO 00 S 0 00 SS OI Oe eo ZERO gt TOUN Valea a oe Zero lL024 25 sly 024 725 Zero 0
134. g pkgs 20 450 g glasses 32 500 g boxes 100 100 g pieces 10 boxes x 8 pieces 30 gift boxes 24 pkgs x 4 pieces 45 pies 10 boxes x 12 pieces 1z 100 g bars LO 4 gg bocccs ADAAN s Confections UnitPrice 12 75 31 23 20 00 14 00 While we are working with this example we have created two reports and swap between them several times This is not very comfortable In order to make the task easier two reports can be placed into one the main report will be on the first page the detail one on the second page In this case the hyperlink needs to be set in the following way 156 Report creation Edit Hyperlink URL Page number Bookmark Report Report page Custom Report page al Pages hal Report parameter SelectedCategoary Specify a parameter value PT or enter the expression that returns a parameter value Categories Category Name je What will happen if you click this object in the preview window Specified page will be generated and opened in separate preview tab Modify the object s appearance so it will look like a clickable link In the given case we need to choose Page2 as the detail report page Example 3 Interactive Matrix object In this example we will see how to build a detailed report if we click on the cell of the Matrix object As an example we will use a matrix which displays the sales of employees grouped by year As
135. ge LastPage OddPages EvenPages RepeatedBand SinglePage This means that the object will be printed on all pages of the report In case the report has single page only the object s visibility is determined by the SinglePage value only We will give several typical examples of using this property Property value Where the object will be printed FirstPage Only on the first page LastPage OddPages EvenPages RepeatedBand On all pages except the first FirstPage OddPages EvenPages RepeatedBand On all pages except the last Only on bands with the RepeatOnEveryPage RepeatedBand property is set to true FirstPage LastPage OddPages EvenPages On all bands except the repeated one FirstPage LastPage OddPages RepeatedBand Only on odd pages FirstPage LastPage EvenPages RepeatedBand Only on even pages For example to print different text on odd and even pages put two Text objects on a band and setup them in the following way e the first object will be printed on odd pages Set its PrintOn property to FirstPage LastPage OddPages RepeatedBand i e all values except EvenPages e the second object will be printed on even pages Set its PrintOn property to FirstPage LastPage EvenPages RepeatedBand i e all values except OddPages These objects will never be printed at the same time You could place them on top of each other Report creation 93 All bands have the same property T
136. geFinished The delayed print feature will not work if you turn on the report file cache Report Options menu Use file cache checkbox Report parameters You can define parameters in a report Parameter is a variable the value of which can be defined both in a report itself and outside of it a program calling a report can transfer parameters values into it See details in Programmer s manual A parameter can be used in expressions and be displayed in report objects like the Text object Most common methods of using parameters e data filtering by condition set in a parameter e printing parameter value in a report 238 Data A parameter has the following properties Property Description Name Parameter s name can have any symbols except dot DataT ype Parameter data type Expression which returns parameter s value More details about Expression expressions can be found in the Expression chapter This expression will be processed when calling a parameter Parameter value This property is not available in the designer and Value can be filled programmatically You have to set up Name and DataType properties The Expression property can be left empty In this case parameter s value should be passed programmatically Creating a parameter To create a parameter select the Parameters element in the Data window right click it and choose the New parameter item in a context menu si T i Par
137. generated and opened in separate preview tab Modify the object s appearance so it will look like a clickable link FastReport passes the values into the SelectedCell Year and SelectedCell Name nested parameters These values will be converted into data types indicated in the parameter configuration this is why it is important to configure parameter data types correctly Detailed report is placed on a separate page of the main report and uses the same data source Report Title _ SelectedCell Name sales in SelectedCell Year year Sere MBER i MONEN 7 Revenue MatrixDemo Mon MatrixDemo Rev In order to show the sales of a chosen employee for a chosen year set up the filtering For this open the Data band editor and indicate the following filtering condition MatrixDemo Year SelectedCell Year amp amp MatrixDemo Name SelectedCell Name The report is ready Run it for execution and click on the top left cell A detailed report will be opened having the following data 160 Report creation Andrew Fuller sales in 1999 year Month Revenue 10 1 900 00 1 2 000 00 As seen the sum of the values 1900 2000 corresponds with the cell of the matrix on which we clicked Example 4 Report with table of contents navigation and outline In this example we will look at creating a report which has the following features e on the first page it will print the Table of Contents TOC which is int
138. he encoding explicitly in the barcode data or set this property to true In this case the encoding will be chosen automatically Use the following control codes in the barcode data Code Meaning 8A START A CODE A amp B START B CODE B amp C START C CODE C amp S SHIFT 8 amp 1 FNC1 amp 2 FNC2 amp 3 FNC3 amp 4 FNC4 If you set the AutoEncode property to true all control codes will be ignored Example of use the control codes amp C 1234 amp B ABC This property is specific to the PDF417 barcode It determines the height to width aspect ratio and is used to calculate the barcode size automatically in case the Columns and Rows properties are not set Fundamentals CodePage This property is specific to the PDF417 and Datamatrix barcode It determines the code page which is used to convert non ASCII chars For example the default windows codepage is 1251 Columns Rows These properties are specific to the PDF417 barcode They determine the number of columns and rows in a barcode If both properties are set to O the size of the barcode will be calculated automatically In this case the AspectRatio property is used as well CompactionMode This property is specific to the PDF417 barcode It determines the PDF417 data compaction mode ErrorCorrection This property is specific to the PDF417 barcode It determines the error correction level PixelSize This property is specific to the PDF417 b
139. he absolute value Example Abs 2 2 2 2 Acos Function Parameters Return value ACOs double d double Returns the angle in radians whose cosine is d d must be in range between 1 and 1 Multiply the return value by 180 Math PI to convert from radians to degrees Example Acos 0 180 Math PI 90 Asin Function Parameters Return value Asin double d double Returns the angle in radians whose sine is d d must be in range between 1 and 1 Multiply the return value by 180 Math PI to convert from radians to degrees Example Asin 0 Q Atan Function Parameters Return value Atan double d double Returns the angle in radians whose tangent is d Multiply the return value by 180 Math PI to convert from radians to degrees Example Data 207 Atan CL 180 y Math Pi 45 Ceiling Function Parameters Return value Ceiling double d double Ceiling decimal d decimal Returns the smallest integer greater than or equal to d Example Ceiling Clad 2 Cos Function Parameters Return value Cos double d double Returns the cosine of the specified angle d The angle must be in radians Multiply by Math PI 180 to convert degrees to radians Example Cos 90 Math PI 180 0 Exp Function Parameters Return value Exp double d double Returns e 2 71828 raised to the specified power d Example Exo 2 71828 Floor Function Parameters Return value Floor double d double Floor decimal
140. he data source in two ways e you can set up the data sorting in the group editor Data source will be automatically sorted on group condition e you can set up the sorting in the Data band editor Both methods are equivalent however it is comfortable to use the first method When creating groups you set up the data grouping and sorting in one dialog In certain situations the first method should not be used Assuming that we will set grouping on the first letter of the product s name In such case the product will be sorted only on the first letter which is not acceptable You should use the second method and indicate sorting on the full name of the product Nested groups A nested group has several Group header bands The last band contains the Data band Group Header Group Header Every group header has its own group condition Creating a nested group can be done in the same way like an ordinary In the first case you create a simple group and add the nested group in the Configure Bands window For this 100 Report creation select the existing Group header band press the Add button and add another Group header band Sao Group Header aaa oh oup He ee Gfoup Footer Group Footer After this call the editor of the added group and set up the group condition In the second case you use the group expert which we have lo
141. he data using the String Format method Get the help on this method in the MSDN Today is String Format 0 d Date Conditional highlighting There is an possibility to change the Text object s appearance depending on the given conditions For example an object can be highlighted with red color if it has a negative value This feature is called conditional highlighting To set up it select the Text object and click ab the button on the Text toolbar You will see the following dialog window Highlight Conditions Conditions It is possible to define one or several conditions and set up the style for every condition Style can contain one or several settings fill text color font object s visibility You can indicate which settings need to be changed when the condition is met For this check the needed setting using the checkbox By default a new style contains one setting the text color In order to create a new condition click the Add button You will see an expression editor 66 Report creation Edit Expression i Data Sources System Variables Here it is possible to write any expression which returns a boolean result In many cases you will use the Value variable which contains the currently printing value Let us look at the following example we have a Text object in which we print the amount of products in stock Products UnitsInStock We want to pa
142. he font size or font width automatically to fit the text This property determines the minimum size of a font or the minimum font width ratio if the AutoShrink property is used This property allows to calculate the width of object automatically This property contains a pair of symbols that designate an expression With this property you can organize the text flow from one text object to another For example we have A and B text objects The A object contains the long text that does not fit in the object s bounds You can set the A BreakTo to B so the B object will display the part of text that does not fit in A This property determines whether it is necessary to clip a text outside of object s bounds It is on by default This property determines how the repeated values will be printed Read more about this property in the Formatting chapter This property determines the offset of the first TAB symbol in pixels Use this property to make the font wider or narrower By default the property is set to 1 To make the font wider set the property to value gt 1 To make the font narrower set the property to value between 0 and 1 This property is of string type It allows to hide values that are equal to the value of this property Read more about this property in the Formatting chapter This property allows to hide zero values Read more about this property in the Formatting chapter This property allows
143. he report code It can neither be moved nor deleted In order to switch to the needed page simply click on its tab Changing order of the pages can be done with the help of the mouse For this left click on the tab and without leaving the mouse move the tab to the desired place R For deleting a page click the fl button This button is not active if the report consists of only one page Fundamentals 17 Page properties Every report page can have its own settings such as paper size orientation landscape or portrait margins columns paper source and others Report template can contain several pages with different orientations and paper sizes The window with page setup can be called by clicking the e Page Setup Paper Margins SOUrCE Columns Other button or by choosing the File Page setup menu item Ad Width 21cm Height 29 7 cm Orientation Portrait Landscape The Paper group allows to set the paper size and orientation It is possible to choose one of the supported sizes by using the drop down list It contains all paper sizes which are Supported by the current printer Current printer can be configured by using File Printer Setup menu The Margins group allows to setup page margins The Mirror margins on even pages options can be used to print booklets Page Setup Paper Margins SOUrCE Columns Other Lett Top Right Bottom Mirror margins o
144. heets but the data is printed in a way that it is comfortable to percept The keep together mechanism allows keeping a set of bands together on one page or column if the report has columns If when printing kept data reaches the end of the page FastReport relocates all data which has been printed already onto a new page You can use the keep together in the following cases e printing all the rows of the Data band together e printing all the elements of a group header data footer together e printing the row of the master data source together with all detail rows in the master detail report e printing the report header or the data header together with at least one data row e printing the report footer or data footer together with at least one data row e printing the parent and child bands together Let us look at the use of keep together mechanism To keep together all data rows or group elements header data footer enable the KeepTogether property This property is used in the Data and Group Header bands The figure below shows how data is printed with and without keeping together 76 Report creation Keep Together False KeepTogether true To keep master data row together with detail data rows enable the KeepDetail property of the Data band This property is used in a report of master detail type KeepDetail False keepDetail true To prevent hanging headers and footers us
145. ike 1 2 1 in a hierarchical report 205 Functions FastReport Net contains a lot of built in functions over 60 All functions are splitted to several categories and are accessible through the Data window Data Sources System Variables Totals i Farameters B Functions E Mathematical H Text H Date amp Time Formatting Conversion a Program Flow You may use a function in any expression in the script see the Script chapter or print its value in the Text object For example the following text in the Text object Sqrt 4 will be printed as 2 Square root of 4 The following expression will return 4 Sqrt 4 2 Let us look at the ways to insert a function in a report e you may drag amp drop a function from the Data window to a report page The Text object will be created which contains a function call You have to edit the text to add parameters to the function call e you Can drag amp drop a function to the script code e in the expression editor you can see a copy of the Data window which acts the same way you may drag items from it and drop them in the expression text Below we will describe each function in details Mathematical Abs Function Parameters Return value Abs sbyte value sbyte Abs short value S109 18 16 Abs int value DAE Abs long value Tong 206 Data Abs float value float Abs double value double ADS decimal value decimal Returns t
146. ill be a dialogue window for setting parameters of the output file 292 Preview print export Export to Rich Text Page range all Current page Enter page numbers andfor page ranges separated by commas For example 1 5 5 12 Options Wiysiayg Page breaks Pictures Metafile yt Open after export Export parameters e Wysiwyg the result will be as close to the report as possible If this option is disabled FastReport will reduce the number of rows and columns in the resulting e Page breaks enables page breaks in the RTF file e Pictures select the format of pictures in the RTF file Note that Metafile format is best for displaying of such report objects as MSChartObject and ShapeObject Appearance and size of the resulting file depends on the report template see the Recommendations on report development section Export to HTML HTML HyperText Markup Language is the predominant markup language for Web pages It provides a means of describing the structure of text based information in a document by denoting certain text as links headings paragraphs lists and so on and to supplement that text with interactive forms embedded images and other objects Export method tabular When exporting into HTML a dialogue window will be offered for setting the parameters Preview print export 293 Export to HTML Page range all O Current page Enter page numbers andor page rang
147. ing data and keeping it together Printing empty data rows Printing No data text Printing hierarchy Master detail report Master master report Master detail detail report Multicolumn reports Page columns Data band columns Booklet type reports Adding page into a report Page settings Printing on odd even pages Groups and totals Creating groups Sorting the data Nested groups Managing groups Printing total values Repeating the header and footer Group properties Subreports Printing modes Side by side subreports Nested subreports Table type reports Configuring columns Managing the size of the column Configuring rows Managing the size of the row Configuring cells Joining and splitting cells Inserting objects in cells Printing a table Printing complex headers 62 63 63 64 66 68 69 70 T1 T1 T1 T1 13 74 15 TT 19 80 83 86 88 89 89 90 92 92 92 93 95 97 99 100 101 102 103 104 106 106 107 107 108 108 108 109 109 110 110 110 111 113 Table of contents Using totals 115 Table layout 115 Examples 116 Example 1 Printing the whole table from top to bottom 116 Example 2 Printing the table from top to bottom with a repeating row 116 Example 3 Printing the whole table from left to right 117 Example 4 Printing a table from left to right with a repeating column 118 Example 5 Printing a table with repeating rows and columns 119 Example 6 Using the data source 120 Exa
148. ing way E Hierarchy Id olurnn Employees EmployeelID Indent 1 5 CH When we run a report we will see the following 80 Report creation EMPLOYEE HIERARCHY Andrew Fuller Vice President Sales Nancy Davolio Sales Representative E Janet Leverling Sales Representative Margaret Peacock Sales Representative Steven Buchanan Sales Manager Michael Suyama Sales Representative Robert King Sales Representative ort When printing hierarchy FastReport shifts the band to the right by a value indicated in the Indent property and also decreases the band width by the same value This allows you to use the Anchor property of band s objects Here is possible values for this property that can be used in this case e Left Top by default the object is moved with the band e Right Top the object stays in its original position e Left Right Top the right side of the object stays at its original position the left side is moved with the band It allows you to get some useful effects Report creation 81 In this example the picture object has Anchor property set to Left Top the object with job title is anchored to Left Right Top the object with the name is anchored to Right Top 82 Report creation Master detail report By using two Data bands it is easy to create a report of the master detail type In this report two data sources between which there is a relation are us
149. int the object red if the amount of products 0 For this we create the following condition Value 0 In the given case we used the Value variable which has got a printed value If there are several expressions in an object then this variable will have the value of the last expression Instead of Value you can use a data column Products UnitsInStock 0 The expression is written in C style This is so if the chosen report language is C For VisualBasic Net you must use the single sign The report language can be changed in the Report Options menu Configure the style for the given condition in such a way that only fill can be used and choose the red color Report creation 67 Highlight Conditions Conditions Style Delete L F F visible When printing an object which has a zero value it will be red Let us make our example more complex we will add another condition If the units in stock is less than 10 it must be printed yellow To do this open the condition editor and click the Add button The second condition will be like this Value lt 10 In case where several conditions have been indicated FastReport checks all the conditions starting from the first one If a certain condition is met FastReport applies its style settings to the object and the process stops It is important to put the conditions in a correct order The order which we have seen in this example is correct 1 Va
150. irectly e indicate an expression which returns the name of the bookmark For example this can be a data column This expression will be calculated when the report is run Link to a detailed report Using this link type you can execute another report and show it in a separate preview window You must set the following parameters for this type of hyperlink e detailed report s name e name of the report s parameter which will take the hyperlink s value e hyperlink value 146 Report creation Edit Hyperlink URL Report name DFR WET ID F tsiInt tive R t Details F zi Pane MANEA 1 Demos Reports Interactive Report Details Fre A Report parameter Bookmark i Category MHame wt Report Specify a parameter value Tr pT or enter the expression that returns a parameter value Custom Categories CategoryHame je What will happen if you click this object in the preview window Specified report will be opened in separate preview tab Modify the object s appearance so it will look like a clickable link When the link is clicked the following will take place e the indicated report will be loaded e the report s parameter will be set to the hyperlink s value e the report will be built and run in a separate preview window Report parameter s value can be indicated by using two methods e indicate the value directly e indicate an expression which returns the value This expression will be calc
151. is gives the advantage of fast development of any reports and their further printing Printed document will look just as on display And this is the primary intent of FastReport report generator usage The downside of such development freedom is the complexity of exporting the FastReport document to different data formats which have their own limits and requirements for information presentation and are sometimes rather complex Many formats such as HTML XLS or RTF use table data presentation These formats do not allow cell crossing or arranging in layers when table marking Preview print export 307 Export filters as a rule take into account these requirements This is carried out by special algorithm which takes object crossings into account and places them optimally At object crossing there are new columns and rows in the resulting output table appear That is necessary for getting maximum resemblance between the result and original report A large number of crossed objects in report design leads to an increased number of columns and rows in the resulting table that affects the file size and its complexity The quality of the export depends greatly on competent design of initial report Let us look at the following example There is a slight crossing of two objects placed one under another on the same band The number of records on report forming was 150 On export to RTF format 450 rows will be created 150 rows for each object
152. ishes spreads and seasonings ProductName UnitPrice 4niseed Syrup 10 00p Chef Anton s Cajun Seasoning z2 00p Ehef Anton s gumba Mix 21 35p In this way you can create a master detail report type with unlimited nested data for example master detail subdetail Another method which is used for the creation of master detail report type connected with the use of nested reports Nested reports will be looked at in the Subreports section Report creation Master master report On the report page you can print several simple lists This can be done by placing on the page two or several Data bands Contrary to master detail report where bands are nested into each other and prints data from related sources in a report of this type both bands and data sources do not depend on each other We will show by an example how to create a report which prints two lists on a page Categories table and Customers table We will create a new report and add into it needed data sources In order to add a second Data band call the Configure Bands window Report Title Page Header aa Data al Fage Footer T Delet CT Report Title al Report Summary Page Header Page Footer T Column Header 7 d Column Footer Header O Footer Right click on an empty place of the list as shown in the figure and select Data band in the context menu This creates a new independent Data band The report temp
153. ist report type with one Data band set the OutlineExpression property of that band As an expression use any data column which is printed in the band e in the master detail report type with two Data bands set the OutlineExpression property of the corresponding bands For example in the Category Product report type the OutlineExpression for the first band will contain the name of the category for the second product s name e in the group report configure the OutlineExpression property of the group header and a Data band As an expression for the group header use the grouping condition For the Data band use any data column which is printed in the band 150 Report creation Examples Example 1 Link to a web page In this example we will create a simple report with one Text object When clicking on the object in the preview window we will move to the FastReport web page Create a new report and add the Text object Write the following text into it Go FastReport home page Right click on the object and select the Hyperlink item in the context menu Configure the link in the following way Edit Hyperlink URL Specify an URL fexample http Sai url corm Att ee Fast report com Page number l pil i or enter the expression that returns an URL Bookmark Report Report page Custom What will happen if you click this object in the preview window Specified URL will be opened Mo
154. it is possible to disable all expressions To do this set the AllowExpressions property to false In this case the text will be shown as is Inside the square brackets you can use any valid expression Read more about expressions in the Expressions chapter For example an object with the following text Je ee will be printed like this 2 2 4 Frequent mistake attempt to write an expression outside the square brackets Reminding that it is considered an expression and gets executed only that which is located inside square brackets For example ZZ 2 2 Iz This text will be printed this way De eae There may be elements inside an expression that needs own square brackets For example it may be a reference to a system variable see the Expressions chapter for details Let s look at the following example The next page Page 1 30 Fundamentals The text contains an expression Page 1 Page is a system variable which returns the number of the current report page It is included in own brackets These brackets must be Square brackets regardless of the Text object settings Strict speaking we were supposed to use two pairs of square brackets when using the Date system variable in the examples above Today is Date However FastReport allows to leave out unnecessary pair of brackets if there is only one member in an expression Displaying the data columns You can print the data column in the follo
155. ject Create a simple report of the following appearance _ Froducts ProductName Products UnitPrice Create a BeforePrint event handler for band Private vold Datel BerorePrint ob jeer sender EventArgs e Engine CurX Int32 Report GetVariableValue Row 10 264 Script If you run the report you will see the following Chai chang Aniseed Syrup Chef Anton s Cajun Seasoning Chef Anton s Gumbo Mix Script 14 00 19 00 10 00 22 00 21 35 265 Dialogue forms Dialogue forms Apart from an ordinary page a report can contain one or several dialogue forms Such dialogue form will be shown when the report is started In the dialogue you can enter any type of information needed for creating a report Also a dialogue may be used to filter data which is Shown in the report For adding a dialogue into a report press the E button on the designer s toolbar A new dialogue looks as follows A report having one or several dialogues works like this e when started the report shows the first dialogue e if the dialogue is closed with the help of the OK button then the next dialogue is shown otherwise the report stops working e after all the dialogues have been shown the report is built Controls On a dialogue from the following controls can be used Icon Name Description ButtonControl Represents a Windows button control Iv CheckBoxControl Represents a Windo
156. late will be like this Configure bands dlt ro i i 2 to 3 1 Report Title Page Header Page Footer Now we will connect the band to the data source and place several data columns on it 86 Report creation Categories CategoryName L Customers CompanyName If we run the report we will see the following Report creation Beverages Condiments Confections Dairy Products Grains Cereals Meat Poultry Produce Seafood Alfreds Futterkiste Ana Trujillo Emparedados y helados Antonio Moreno Taqueria Around the Horn a p T re E A B 87 Master detail detail report A Data band can contain one or several nested Data bands This allows building a master detail detail report type To do this call the Configure Bands window right click on the master Data band and add a detail Data band to it Repeat this procedure in order to add the second detail band 7 aa Data 3 Data In this way it is possible to add an unlimited number of detail bands to the master Data band An example report structure can be like this this is just an example it only demonstrates the abilities of FastReport sa Data Sa Data sa Data Data Data 88 Report creation Multicolumn reports An ordinary report prints data as long as it has not reached the end of the page After this a new page is formed and printing continues on it A report with columns prints data in several c
157. le property of the band or its objects The property contains a style name which will be used to highlight even band rows It is preferable to use the EvenStyle property of the object instead of the band This avoids possible problems when exporting the report In order to configure the highlighting do the following 1 Define the style which will be used for highlighting the rows This can be done in the Report Styles menu 2 Indicate the name of the new style in the EvenStyle property of the band or its objects By default objects use only a fill property of the style given in the EvenStyle property This behavior is defined in the EvenStylePriority property by default it is UseFill If you need to use the rest of the style parameters set this property to UseAll A ready report which uses this technique can look like this Product name Unit price Chai 16 00 Chang 19 00 Chartreuse werte 16 00 Cote de Blave 263 50 Guarana Fantastica 4 50 Ipoh Coffee 46 00 4 70 Report creation Report with one Data band This type of a report is more often required It allows printing a list of rows from the data source For example this can be a customer list Connecting a band to data source To print a data from the data source you will need the Data band which is supposed to be connected to the data source The band will be printed as many times as there are rows in the data source If the Data b
158. le matrix To do this invoke the context menu of the Matrix object and choose the style Report creation 127 Row and column size management Since the Matrix object is a kind of Table object it allows setting row and column sizes in the same way By default a matrix has got the AutoSize mode enabled In this mode the matrix calculates the column row sizes automatically You can as well manage the size of the object manually To do this disable the AutoSize property of the matrix Rows and columns have the same property you can use it if autosize of the matrix is disabled In order to limit the minimum and maximum width of a column select a column and set up its MinWidth and MaxWidth properties In order to limit the minimum and maximum height of a row select a row and set up its MinHeight and MaxHeight properties 128 Report creation Examples Let us look at examples of using the Matrix object For a start create a new report and put the Matrix object on the Report Title band You can also use the Data band in that case there is no need to connect the band to a data source In the given case it does not matter on which of the two bands you will put the matrix since both bands will be printed once when the report is started The report looking as follows Drag data here to create a new row Drag data hereto create a new column Drag data hereto create a new cell Do not put Matrix o
159. le to the Dropbox by pressing the Save button and selecting Dropbox When exporting to a Dropbox for the first time the Application Info window will be displayed Application Info L a8 Application Key Application Secret Enter the Application Key App key and Application Secret App secret obtained above After clicking the OK button FastReport NET saves these values and uses them again the next time The Save to Dropbox window has two tabs File and Proxy Preview print export 303 i Save to Dropbox n File Prepared report Proxy The File tab contains the following fields FTP Server enter the URL address of the FTP server Username and Password enter your username and password File Type select the file format prepared report or one of the export formats from the drop down list If an export format is selected then the Settings button becomes available which opens the settings window for the chosen export format If a proxy server is used then the URL address port username and password of the proxy server are set on the Proxy tab Save to Dropbox I l ES Username Password When all settings have been made click the OK button to save the file to the Dropbox Export to Google Drive A prepared report can be saved to Google Drive from the FastReport NET preview The report can be exported to one of the supported formats before b
160. ll the object will be growing and Shrinking synchronously with container By default the value of this property is Left Top This means that when the container s size will be changing the object will not be changing In the table below combinations of some frequent used values are given Value Left Top Left Bottom Left Top Bottom Left Top Right Bottom Dock property Description Value by default The object does not change when the size of the container changes The object moves up down when the height of the container changes The position of the object in relation to the bottom edge of the container does not change When the height of the container is changing the height of the object synchronously changes with it When the width and the height of the container are changing the object grows or shrinks synchronously with it Every report object has this property This property determines on which side of the container the object will be docked The Dock property can have one of the following values Value Description None Value by default The object is not docked Left The object is docked to the left edge of the container The height of the object will be equal to the height of the container Top The object is docked to the top edge of the container The width of the 60 Report creation object will be equal to the width of the container The object is docked to the right edge of the contain
161. ll be opened Modify the object s appearance so it will look like a clickable link Choose the type of hyperlink by selecting the tab in the left side of the window After you have done you may click the Modify the object s appearance checkbox at the bottom of the window The appearance of the object will change in the following way e blue color will be set for the text and it will underlined e a hand cursor form will be set In some cases hyperlink needs to be shown in the preview window but there is no need to print it This is easy to do if you disable the Printable object property This can be done in the Properties window Link to the URL Using this type of link you can e navigate to the given internet address e execute some kind of system commands for example mailto for sending an email When clicking on the link of this type the System Diagnostics Process Start method is executed with the link s value as a parameter You can indicate the value of the link by using two methods e indicate the value directly for example http www fast report com e indicate an expression which returns the value of the link This expression will be calculated when you run the report Report creation 145 Link to the page number By using this link type you can organize navigation on the pages of a prepared report Most often navigation to the first page is used For this indicate the page number 1 in th
162. logue has been closed by the OK button FastReport applies data filter automatically By default the property is set to true If it is disabled the filtering will not happen and you must do it yourself by calling the FilterData method ListBoxl FilterData Examples Example 1 Hello FastReport In this example all we will do create a dialogue which will be showing greetings Create a new report and add a dialogue to into For this press the El button on the toolbar Dialogue forms 275 On the dialog place the LabelControl and set its Text property in the Properties window If you run the report you will see the dialogue Close it by the OK button and the report will be built If the dialogue is closed by the Cancel button or by the X button the report will stop working and you return to the designer Example 2 Ask for a text from the user In this example we will create a dialogue which will be asking for an arbitrary text from the user and later print the entered value in the report Create a new report and add a dialogue into it On the dialogue place LabelControl and TextBoxControl controls 276 Dialogue forms In the given case the value we have entered is contained in the Text property of the TextBoxControl In order to print this value in the report add a new Text object on the Report Title band and write the following in it You have entered TextBox1 Text where
163. longs to and looks just the Same as in the designer In this mode the table does not split across pages if its width is bigger than the width of the report page This is the mode of printing by default The second mode is dynamic In this mode the table is built with the help of script During this the resulting table can be different from the initial table just like the prepared report of FastReport differs from the report template In dynamic mode the table can split across pages if it does not fit on the report page In the dynamic mode the table does not get printed on the band on which it was placed Instead of this the table itself generates a set of bands which contain parts of the resulting table This mode of work imposes the following limits e never put other objects under the table or near it Instead of this use the Child band e never put two Table objects on one band Let us look at the dynamic mode in details This mode is connected with programming and needs higher qualifications from the report developer Formation of the table is done with the help of script In order to create a script select the Table object in the Properties window click the Events button and double click on ManualBuild event Report creation 111 Properties I x Tablei TableObject sd AfterFrint BeforePrint ManualBuild Table 1 ManualBuild EO Preview tS Click When this is done an empty event handler is added int
164. lor for example will still be reflected in the inherited report This behavior will become clear if we look at the contents of inherited report file For example this is how the original object is saved in the inherited report in case this object was not changed lt inherited Name Text1 gt If we change the object s location in the inherited report it will be saved like this lt inherited Name Text1 Left 255 15 Top 28 35 gt When opening the inherited report FastReport will load all object s properties defined in the base report plus properties saved in the inherited report Limitations The report inheritance was designed to meet the following goal save common report elements such as headers and footers in separate files and reuse them in inherited reports Do not try to use the inheritance to perform more complex tasks In particular avoid to do the following do not inherit the report from the inherited one i e do not inherit twice do not use complex objects such as Table and Matrix in the base report do not use script in the base report do not use parameters in the base report Report creation 165 Reports with charts FastReport uses Microsoft Chart library to display charts This library will be included in Net Framework 4 0 Now it is available as a separate download here This library requires Net Framework 3 5 SP1 It is freeware you can learn about its features here http code msdn mic
165. lue 2 Value lt 10 If we swap conditions then the highlighting will work wrongly 1 Value lt 10 2 Value 0 In the given case the Value 0 will not be executed because when the value is zero then oul the first condition will be met In order to change the order of the conditions use the and buttons Hiding zero values The Text object has the HideZeros property which can be used to hide zero values Lets look at an object with the following contents Total elements CountOfElements If the value of variable CountOfElements is equal to 0 and the property HideZeros is set to true the object will be printed as follows 68 Report creation Total elements The Text object also has the HideValue property which can be used to hide the value of an expression which is equal to the given value For example if the property value is 0 then all the zero fields will be hidden This property can also be used for hiding zero dates As a rule it s a date like 1 1 0001 or 1 1 1900 In this case the value of HideValue property must be like this 1 1 1900 0 00 00 As you can see apart from the date you need to indicate time as well This is necessary because the value of the date in Net contains time also Important note this mechanism depends on the regional settings of your system which can be set in the control panel This happens because FastReport compares strings using the ToString meth
166. lue starts with A will be chosen Adding filter into a report FastReport s dialogue designer has got very comfortable facilities for adding controls which Support the data filtering For this drag amp drop the data column from the Data window onto the dialogue from During this FastReport creates the header LabelControl control and an actual control which will be used for data filtering Employee The control type depends on the type of the data column If the column is of string type then after inserting it you will be offered to choose the control type TextBox MaskedTextBox ComboBox CheckedListBox ListBox J l4 DataSelector If you have inserted two similar controls connected to the same data column FastReport automatically configures the data range with the help of the FilterOperation property The first control will have FilterOperation GreaterThanOrEqual the second LessThanOrEqual This will be done in case if you insert a column which is not of string type As such for adding data filtering into any report you need to do the following e add a new dialogue into the report e drop onto the dialogue a data column on which you want to filter the report Dialogue forms 273 Filtering on data range This method of filtering is comfortable for using when working with values having a quantitative characteristic for example the cost You can filter goods having the cost less than
167. matically converted to any type For example float tax Report GetTotalValue TotalSales 0 2f Reference to the total value can be done at that time when it is being processed Usually the total is ready to use at the moment of printing the band on which it is located in the report Reference to report parameters For referring to report parameters use the GetParameterValue method of the Report object int myParam int Report GetParameterValue MyParameter Parameters can be nested In this case indicate the name of the parent parameter and after the period the name of the child parameter Script 259 Report GetParameterValue ParentParameter ChildParameter Parameters have got a definite data type It is given in the DataType property of the parameter You must take this into account when referring to parameters You can see a list of parameters in the Data window From it you can drag parameters into the script during this FastReport automatically creates a code for referring to the parameters For changing the value of the parameter use the SetParameterValue method of the report object Report SetParameterValue MyParameter 10 260 Script Examples Example 1 Changing object s appearance In this example we will show how to change the color of the text depending on the value printed in the object We will be using e the BeforePrint event e reference to the data column from script Create a
168. may have different number of values because some employees do not have sales in this particular year To align series values check the Align X values checkbox We will get the following result 176 Report creation Items sold per year 8 Mb 1999 Wy 2000 6 2001 MB 2002 4 Andrew Janet Nancy Steven Fuller Levering Davolio Buchanan Interactive charts The chart as well as other report objects can be interactive You can set up chart in the way that when you click its value another detailed report will be executed and shown To do this you need to set up the Hyperlink property as described in the Interactive reports chapter The chart will pass the value to a hyperlink by itself when you click on its element Let us observe the Charts Interactive Chart report from the FastReport demo program Create a report with two pages The first page will contain a chart the second one will contain a detailed report that will be displayed when you click a chart value Place the Chart object on the first report page and set up its properties in the chart editor e select the Chart element from the series list and choose the MatrixDemo data source e select the series from the series list and set up X and Y values X MatrixDemo Name Y MatrixDemo ItemsSold Name Series Data processin p Li X value Appearance Y value T Color Fill amp border Eo lnii r Cle a Ta i a D a a T A Te a F TE e swi
169. more about this in the Report Creation chapter If the property is enabled FastReport tries to print a part of the band s contents on the available space that is break the band Read more about this in the Report Creation chapter Printing a band with such property begins on a new page This property is usually used when printing groups that is every group is printed on a new page 25 PrintOnBottom RepeatOnEveryPage 26 A band with this property is printed at the bottom of the page before the Page Footer band This can be useful when printing certain documents where the total sum is Supposed to be printed at the bottom of the page The bands Data Header Data Footer Group Header and Group Footer have got this property This type of band will be printed on each new page when data printing is being done Read more about this in the Report Creation chapter Fundamentals Report objects A wide variety of objects can be used in a report Icon Name Description Text A Text Object Displays one or several text lines z Picture PictureObject Displays a picture Line Displays a line A line can be vertical LineObject horizontal or diagonal z Shape Displays one of the geometrical shapes ShapeObject rectangle ellipse triangle and others Rich Text l 4 RichObject Displays a formatted text in RTF format Barcode l HII HH Bar
170. mple 7 Inserting page breaks 121 Example 8 Printing totals 122 Matrix type reports 123 A few theory 123 Configuring the matrix 124 Configuring headers 126 Configuring cells 126 Styling the matrix 127 Row and column size management 128 Examples 129 Example 1 Simple matrix 130 Example 2 Multilevel headers 131 Example 3 Printing the name of the month 132 Example 4 Conditional highlighting 133 Example 5 Highlighting even rows 135 Example 6 Using Expressions 136 Example 7 Pictures in cells 137 Example 8 Objects in cells 138 Example 9 Filling a matrix manually 140 Interactive reports 144 Hyperlink 144 Hyperlink configuration 144 Link to the URL 145 Link to the page number 146 Link to a bookmark 146 Link to a detailed report 146 Link to a detailed page 147 Custom link 148 Report outline 149 Examples 151 Example 1 Link to a web page 151 Example 2 Building a detailed report 152 Example 3 Interactive Matrix object 157 Example 4 Report with table of contents navigation and outline 161 Report inheritance 163 Creating a report 164 Changing the base report 164 Limitations 165 Reports with charts 166 Chart elements 166 Chart editor 167 Table of contents 5 Handling series Setting up the appearance Connecting chart to data Sorting the data Grouping the data Collecting the data Exploding the values Setting up auto series Interactive charts Reports with maps Map elements Controlling the map with the mouse The Map
171. n Filter tab Employees EmployeeID EmployeelID TO pass parameter value from your program to the report use the following code reportl SetParameterValue EmployeelID 2 240 Data Expressions Expressions In many places in FastReport expressions are used For example the Text object can contain expressions in square brackets An expression is a code in C or VB Net language which returns any value For example 2 p2 An expression should be written in a language chosen as a script in a report By default it is C You can change the language in the Report Options menu by choosing the Script element in a window Report Options General Script language Description CH VisualBasic NET Script Moke iF you change the language entire script will be cleared Security Referenced assemblies Inheritance System dl System Drawing dll System Windows Forms all System Data dll System ml dil 242 Expressions Expression editor To write an expression quickly use the expression editor It can be invoked in such places of FastReport UI where you can type an expression Group condition Select data column or type an expression Products ProductName Substring Q 1 Press to display the Visible True expression editor El Data DataSource Employees The expression editor presents a window where you can write an expression and insert some data element
172. n connection type will be used by default 3 Connection settings 4 Test connection button Connection with MS Access data base is shown in the picture If another type of connection is chosen then connection settings area 3 will be changed For example connection to MS SQL Data 193 data base has the following settings Connection Select the connection type MS SQL connection w Always use this connection Server name ASOLEXPRESS Log on to the server Use Windows Authentication O Use SQL Server Authentication hss Connect to a database Database name gt Database file d Login prompt Choose the needed connection type and set up its parameters After pressing the OK button the window will be closed and you will return to the data wizard window Next you need to set a connection name This name will appear in the Data window Enter the connection name Connection Press the Next button to continue Here you will be offered to choose tables which are accessible in the data base 194 Data Data Wizard Choose tables Which tables you want in your report EM casi cross 1E long table 4dd SQL query Tick off the needed tables and close the wizard by pressing the Finish button Now you can see in the Data window a connection created by you which contains the chosen data sources Data Sources Connection H E crass System Variables Dat
173. n even pages The Source group allows choosing the source of the paper Note that the sources can be 18 Fundamentals given separately that of the first page of the prepared report and that of the rest of pages Page Setup Paper First page Margins Other pages Source Columns Other The source can be chosen in the Print dialog as well The Columns group allows setup the column parameters for multi columned report For this the number of columns need to be indicated and optional correct the width of the column and the position of every column Page Setup Paper P Count Positions Source Columns Okher Cancel The Other group allows giving certain helpful page properties It is possible to indicate duplex mode for duplex printing if your printer supports this mode Here it is also possible to set the watermark which will be printed on prepared report pages Fundamentals 19 Page Setup Duplex Margie Default Edit watermark Source Columns Extra design width The Extra design width checkbox allows to increase the page width in the design mode It may be useful if you work with such objects as Table or Matrix The duplex mode can be chosen in the Print dialog as well 20 Fundamentals Bands The band is an object which is located directly on the report page and is a container for other objects like Text Picture and others In all in Fa
174. n the left of the current cell in which we are calculating the sum are analyzed Table layout The table which is built dynamically can be automatically splitted across pages This behavior is controlled by the Layout property of the table You can choose one of the following values Value Description AcrossT henDown Table is rendered across then down DownThenAcross Table is rendered down then across Wrapped Wide table is wrapped and rendered on the same page Report creation 115 Examples Let us look at printing tables for example As a template we will use the following report To start select the table and create an event handler for ManualBuild event Example 1 Printing the whole table from top to bottom private void Tablel ManualBuild obj ect sender EventArgs e printing row 0 and all of its columns Tablel PrintRow 0 Tablel PrintColumns printing row 1 and all of its columns Tablel PrintRow 1 Tablel PrintColumns Printing row 2 and all of its columns Tablel PrintRow 2 Tablel PrintColumns As a result the following table will be printed which does not differ from the template Example 2 Printing the table from top to bottom with a repeating row private void Tablel ManualBuild object sender EventArgs e Id Printing row 0 and all of its columns Tablel PrintRow 0 Tablel PrintColumns 116 Report creation In this example the middle row gets printed 3
175. n which you can perform the needed filtration The query will be executed on the data server and return only those rows which are needed in the report You also may use dialogue forms to perform data filtering See more details in the Dialogue forms chapter Report creation 73 Data header and footer A Data band can contain a header and a footer The header will be printed once before data the footer will be printed after the output of all data In order to add a header and footer to a Data band choose the Report Configure Bands menu item In the widow select the Data band and right click the mouse In the context menu choose the Header and or Footer items Contigure Bands Delete J Report Title al Report Summary E Page Header T Column Header d Column Footer 4am Group Header E Overlay Namet Bookmark Border CanBreak Cantarow CanShrink Columns CUFSOr DataSource Evenstyle EvenstylePriority Fill Filter The object s name These bands can be useful in the following situations Datal Border False True True BandColumns Default Employees UseFill Solid e when printing several lists on one page master master reports Every data band in this case can have its own header and footer 714 Report creation cu cu r Tp cu EL md mI e when printing one list if the list does not fit on one page of the prepared report By usin
176. ned in the following assemblies System dll System Drawing dll System Windows Forms dll System Data dll System XmIl dll Apart from that you can use any object defined in the FastReport assembly If you need access to another assembly add it to the list of assemblies This can be done in the Report Options menu by choosing the Script tab Script 253 Referenced assemblies System dll System Drawing all System Windows Forms dll System Data dll System sml dll For example if you want to use a function in your report which was declared in your application add application assembly exe or dll in a report assemblies list After that you can call the function by using namespace of your application For example if the following function is defined in application namespace Demo public static class MyFunctions Public static string Func return Hello Calling it in the script can be done in the following way string hello Demo MyFunctions Funcl If you add the using Demo line at the top of the report s script it will allows you to shorten the syntax string hello MyFunctions Funcl Reference to report objects For referring to report objects for example Text object use the name of the object The following example returns the height of Text1 object float height Textl Height Note that report s native unit of measurement is screen pixels Ke
177. ng the following e get the data source defined in the report e initialize it fill it with data e print the table s rows as many times as there are rows in the data source Here is the code of the handler private void Tablel ManualBuild object sender EventArgs e get the data source by its name DataSourceBase rowData Report GetDataSource Products f f initialize it rowData Init printing the table header Tablel PrintRow 0 Tablel PrintColumns loop through the data source rows while rowData HasMoreRows printing the table row Tablel PrintRow 1 Tablel PrintColumns select the next data row rowData Next 120 Report creation j printing the table footer Tablel PrintRow 2 Tablel PrintColumns If we run the report we will get the following ProductName Umtpree Unies Tn Stocke Chef Anton s Gumbo Mix 135 os Grandma s Boysenberry Spread 25 00 oOo ae Uncle Bob s Organic Dried Pears 30 00 a Northwoods Cranberry Sauce Example 7 Inserting page breaks Using the PageBreak method of the Table object you can insert a page break when printing a table Call it before you print a row column We will use the Example 1 to demonstrate how the PageBreak method works Let us print the third row on a new page private void Tablel ManualBuild object sender EventArgs e print the row 0 with all its columns Tablel PrintRow 0 Tablel PrintColumns
178. ns Another method of printing a multicolumn report is based on using the Data band columns The rest of the bands continue to be printed in one column Column parameters can be configured using the Columns property which can be changed in the Properties window You can set up the following parameters e number of columns e column width e column printing mode You can select either of the two modes AcrossThenDown and DownT henAcross e the minimum number of rows in one column if the chosen mode is DownThenAcross Column band can be printed in either of the two modes In the AcrossThenDown mode the default one columns are printed in the following way In the DownThenAcross mode column printing occurs in the following way 90 Report creation Data 1 Data 4 Data 2 Data s Data 8 Dae 3 Data 6 W In this mode FastReport calculates the number of data rows in a column in such a way that columns are filled equally You can also set the minimum number of rows in a column with the Columns MinRowCount property Report creation 91 Booklet type reports When printing a report in form of a booklet you will probably face with the following demands e separate report page cover table of contents report contents back cover e different page margins for even and odd pages e different header and footer on even and odd pages Adding page into a report You can add any number of pages into
179. nsparentColor Image DataColumn ImageLocation Padding ShowErrorImage 38 Description The rotation angle in degrees Possible values for this property are 0 90 180 270 The size mode The degree of transparency of the pictures The property can have values between O and 1 The value O by default means that the picture is opaque The color which will be transparent when displaying the picture The picture The data column that this object is bound to This property can contain name of the file or URL The picture will be loaded from this location when building the report The padding in pixels Shows the No picture picture in case when the picture is empty This property makes sense to use if the picture is downloaded from the Internet Fundamentals The Line object The Line object can display horizontal vertical or diagonal line The object is as follows If possible use the object s border instead of Line object This will simplify the report and avoid possible problems with the export to different formats FastReport designer has convenient tools for drawing a line In order to insert a line into a report click the button on the Objects toolbar and in the menu choose the Line object or Diagonal Line Place the mouse cursor at the location where the line will start from Then left click and hold the mouse in order to draw the line After this you can draw the line again When
180. nted the Report Summary band is printed and at the bottom of the page the Page Footer band Printing of the report ends with this A prepared report will be looking something like this 24 Fundamentals Report Title Page Header Data Data Data Data Data Data Data Page Footer Page Header Data Data Report Summary Fage Footer In the process of printing FastReport checks if there is enough space on the current page of the prepared report so that the band can be printed If there isnt enough space the following occurs page footer is printed a new page is added page header is printed Band properties continues to print the band which did not fit on the previous page Every band has several useful properties which affect the printing process They can be configured by using the band s context menu To do this right click on an empty space on the band not occupied by other objects Also it is possible by clicking on the band header if the classic display mode is used or on band structure otherwise Another method choose a band and change the corresponding properties in the Properties window Property CanGrow CanShrink CanBreak StartNewPage Fundamentals Description These properties determine whether a band can grow or shrink depending on the size of the objects contained in the band If both properties are disabled the band will always have the size specified in the designer Read
181. o enable the smooth mode when drawing graphical objects line border picture On the Description tab you can give the description of the report All these parameters are not obligatory and they serve for informational purposes 14 Fundamentals Report Options General ieme Description Author Version Description Demonstrates simple list report To cr E Security Picture Load Inheritance Clear F Save Preview picture Created 17 01 2005 3 05 57 Modified 05 11 2004 23 56 23 On the Script tab you can choose the script language for the report Detailed work with script can be found in the Script chapter On the Security tab you can give the password which will be requested when opening the report A report which has a password is saved in an encoded form so do not forget your password Restoring a report in this case will be practically impossible On the Inheritance tab you can control report inheritance This functionality will be looked at later Fundamentals 15 Report pages Template consists of one mostly or several report pages Report page in turn contains bands Report objects like Text Picture and others are placed on the band Report t late contat z fi ees a The page contains bands The band contains objects Pagel Name GE E p Pages Report template can consist of several pages For example you can create a template containing title page and a page wi
182. o print different bands on odd and even pages use the Child band You can attach it to any band this can be done in the Configure Bands window Setup the main band and its child in the following way e the main band will be printed on odd pages Set its PrintOn property to FirstPage LastPage OddPages RepeatedBand i e all values except EvenPages e the child band will be printed on even pages Set its PrintOn property to FirstPage LastPage EvenPages RepeatedBand i e all values except OddPages Bands can have different height appearance and contents Look at the following example which prints different page headers Page Page Header z L 4 PageN Child 4 94 Report creation Groups and totals Earlier we looked at the Master detail report type which printed data from two related sources FastReport allows creating a report which looks in the same way but uses one data source For this groups are used A group is a set of three bands Group header Data and Group footer In designer this looks as follows Group Header A group always contains a header and data Group footer is optional you can delete it In order to use a group you should set the group condition for the group header and connect the data source to the Data band The condition can be any expression but as a rule this is one of the data
183. o the report code private void Tablel ManualBuild obiecr sender EventArgs In this mode the source table is used as a template In the event code you can print rows and columns from the source table as many times as it is needed During this the resulting table will be formed which can contain an unlimited number of rows and columns Such a table can split across pages if it does not fit on the report page For printing a table the following methods of the Table object are used Method Parameters Description Prints the row with the specified index Row numbering PrintRow int index aA ae PCN Aande Prints the column with the specified index Column numbering starts from 0 PrintRows int indices Prints several rows of the table PrintRows Prints all rows of the table PrintColumns int indices Prints several columns of the table PrintColumns Prints all columns of the table PageBreak g Inserts a page break before printing the next column or row Printing a table can be done by using one of the following methods The first method printing from top to bottom then from left to right This method fits better a table with a variable amount of rows You must call the methods in the following order PrintRow row index one or more calls of the PrintColumn column index or PrintColumns columns indices methods for printing the indicated columns or one call of the PrintColumns method for printing all
184. ob ect sender A SSSeeSeee printing row 0 Tablel PrintRow 0 printing column 0 Tablel PrintColumn 0 printing 3 copies of column 1 for int i Us i Be is Tablel PrintColumn 1 jf Printing column 2 Tablel PrintColumn 2 J le ce tetas printing 3 copies of row 1 for int J 0 J lt 3 Jtt Tablel PrintRow l1 printing column U Tablel PrintColumn 0 printing 3 copies of column i for Inke 1 UF 2 lt BF a TabL el PrinvCol umn 1 4 7 preinting column z2 Tablel PrintColumn 2 ae printing row 2 Tablel PrintRow 2 Printing column 0 Tablel PrintColumn 0 f f printing 3 copies of column 1 tor int i Of 1 lt Se i Tablel PrintColumn 1 Jf printing column 2 Tablel PranceCo lumn 4 EventArgs e Pay attention that we printed the same number of columns in every row If this rule is violated then we will get an unpredictable result In this example the middle row and middle column of the table were printed 3 times And as a result we get the following Report creation 119 Example 6 Using the data source In all the examples considered we printed a table which contains an ordinary text In this example we will show how to forma table using data source For this we will create a table having the following form Products ProductName Products UnitPrice Products UnitsInStock We will create the ManualBuild event handler which will be doi
185. od This method converts an expression value into a string In relation with this be careful when building reports which can be launched on a computer with different regional settings Finally the NullValue property of the Text object allows to print some text instead of a null value It is often used to print the dash instead of a null value Lets look at an object with the following contents Total elements CountOfElements If the value of variable CountOfElements is null and the property NullValue is set to the object will be printed as follows Total elements Hide duplicate values The Text object has Duplicates property which allows to control how duplicate values will be printed This property can be used if the Text object is on the Data band The values considered duplicate if they are printed in the near by data rows The Duplicates property can have one of the following values Show show the duplicates by default Hide hide the object with duplicate value Clear clear the object s text but show the object Merge merge several objects with the same value The difference between these modes in shown in the figure below Report creation 69 Duplicates Show Duplicates Hide Duplicates Clear Duplicates Merge Highlight odd even data rows In order to improve the appearance of a report you can highlight even data rows in different colors This can be done by using the EvenSty
186. of ESRI shapefile type The base layer the first one is configured to display a country map for example and the second layer geodata from an application displays points city names where sales occurred The color and size of a point can be configured to reflect sales level If the ESRI shapefile layer type is chosen select how the map data is stored from the whole map data is embedded in the report file In this case the report file frx may be large the report file holds a reference to the map files shp dbf This mode is useful if several reports use the same map files Large map files more than 30Mb or map files containing a lot of polygons more than 20 000 182 Report creation Slow down report generation Setting up the layer appearance To set the layer appearance choose the layer and switch to the Appearance tab Size ranges Labels Set the border color and style of the map polygons and choose the color palette Note that W Visible Border color Border style Border width Fill color Palette the palette is ignored if you configure the color scale more about this later Setting up label display The map can display labels such as country names Set the label type and appearance on the Labels tab Data Appearance Color scale Size ranges Labels Report creation 183 If the ESRI shapefile layer type is chosen set the field name which
187. of the top and bottom margins float PageFooterHeight Height of the page footer and all its child bands float ColumnFooterHeight Height of the column footer and all of its child bands float FreeSpace Size of the free space on the page bool FirstPass Returns true if the first or only report pass is being executed Number of passes can be obtained from the Report DoublePass property bool FinalPass Returns true if the last or only report pass is being executed On the figure below you can see the meaning of some properties listed above Engine FreeSpace Engine PageHeight h E EEE T _ Engine Page Width 5 Engine PageWidth and Engine PageHeight properties determine the size of the printing area which is almost always less than the actual size of the page Size of the printed area is determined by the page margins which is given by the LeftMargin TopMargin RightMargin and BottomMargin page properties Engine FreeSpace property determines the height of the free space on the page If there is the Page footer band on the page its height is considered when calculating the FreeSpace Note that after printing a band free space is reduced How does the formation of a prepared report page take place FastReport engine displays bands on the page until there is enough space for band output When there is no free space the Report footer band is printed and a new empty page is formed Displaying a band starts from
188. oked at already Set the grouping condition and click the Add button The wizard will add the new group to the existing one Printing of the nested group does not differ much from printing of an ordinary group When printing data FastReport will check all group conditions of all groups If the condition changes the corresponding group finishes and a new group starts printing Managing groups For managing groups the group expert can be used It can be called from the Report Group Expert menu Group Expert Group condition Select a data column or type an expression then press Add button to add a new group rere Category ame SupplierID Cancel Report creation 101 With the help of the wizard you can either add or delete a group and change the grouping order as well For changing the grouping order the buttons and are used With the help of the Edit button you can change the group condition of the chosen group Printing total values Grouping is often used for printing some total values in every group For example this can be the number of rows in the group or sum from one of the data columns For printing such values the total is used The use of totals is described in the Data chapter In order to print the total value in the group you need to do the following create a total by selecting the Actions New total item in the Data window choose the group s data band in the E
189. ollowing operations Operation Equivalent Effect Equal Filter the value if it is equal to the control s value NotEqual lt gt Filter the value if it is not equal to the control s value LessThan lt Filter the value if it is less than the control s value LessThanOrEqual lt Filter the value if it is less than or equal to the control s value GreaterT han gt Filter the value if it is greater than the control s value GreaterT hanOrEqual gt Filter the value if it is greater than or equal to the control s value For example if the FilterOperation property of the control is set to LessThanOrEqual and you enter the value 5 in the control then all the data rows will be chosen for which the corresponding column value is less than or equal to 5 For the data of string type you can use extra operations Operation Effect Contains Filter the value if it contains the control s value 272 Dialogue forms NotContains Filter the value if it does not contain the control s value StartsWith Filter the value if it starts with the control s value NotStartsWith Filter the value if it does not start with the control s value EndsWith Filter the value if it ends with the control s value NotEndsWith Filter the value if it does not end with the control s value For example if the FilterOperation property of the control is set to StartsWith and you enter the A then all data rows whose corresponding data column s va
190. olumns iA X Dz e Marne RowID Alias RowID BindableContro Text Calculated False DataType Int32 Expression Name The object s name If you made a mistake in the query text or in the parameter definition you will see error message when turning to the last page of the wizard As a rule it is enough to be assured that the query has returned all the needed columns On this step you can do the following e delete unnecessary columns using the Delete button e reset the columns by pressing the Refresh button e add a calculated column by pressing the Add calculated column button For a new column it is necessary to set the Name DataType and Expression properties After closing the wizard by pressing the Finish button you will return to the Data wizard window Query parameters There can be parameters in a query text Let us see the following query select from DVDs where Title paraml This is the query to MS SQL demonstration database The parameter with parami name is defined in a query Here it should be noted method of describing parameters in a query differs for different DBMS For MS SQL a parameter is marked by a symbol MS Access parameters do not have names and are marked by the symbol If your SQL query contains parameters you have to declare them It can be done in the third step of the Query Wizard which we have looked at above To create a parameter press the Add par
191. olumns When the end of the page has been reached printing continues in a new column on the same page In this sense an ordinary report can be seen as a report with one column In FastReport there are two methods of printing columns Page columns The first method is based on setting the number of columns of the report page This is done in the Page Setup window on the Columns tab Page Setup oun Positions SOURCE Columns As seen you can set the following column parameters e column count e column width e the position of every column In order to transform an ordinary report into a report with columns you need to set only the number of columns on the page The rest of the parameters FastReport will calculate on its own When you enable columns the mode of bands in the designer changes Report Title Page Header Page Footer Report creation 89 The area shown in grey should never be used for placing objects on it It is used to print next columns objects For working with columns the Column Header and Column Footer bands are used As seen from their names they print at the top and the bottom of every column respectively The following figure demonstrates the bands printing order in the report with columns Page Header Column Header coffin Header Data Fi Data bate Fi Data Data f Data bata Column Footer Data bata Data Column 7 Fa kF j 2 Page Footer Data band colum
192. or printing different objects on an ordinary group header and on repeat for example printing the continue text on a new page For this use the PrintOn property of the Text object see more details in the Booklet report type section In order to print different texts place two objects on the group header one on top of the other e the first object will be printed on ordinary headers Set its PrintOn property value to FirstPage LastPage OddPages EvenPages that is all values except the RepeatedBand e the second object will be printed only on the headers which are repeated Set its PrintOn property to RepeatedBand Add the Text object with continue text on the header The report will be printed as follows Report creation 103 Group footer can also be repeated on every page Raclette Courdayault Ravioli Angelo Rh nbr u Klosterbier R d Kaviar Reigede sild gpm T ee a R ssle Sauerkraut 45 60 Total products 6 In this report the group footer has two objects placed one on top of the other F Total products TotalProducts k PrintOn FirstPage LastPage OddPages EvenPages e amp Printon RepeatedBand l Group properties The Group Header band has some useful properties The StartNewPage property allows forming a new page before printing the group As a result each group will be placed on a new page 104 Report creation The new page
193. ory Manne Products ProductName If we run the report the following will be seen 96 Report creation Beverages Cote de Blaye Chartreuse werte Steeleye Stout Guarana Fant stica Sasquatch ole Rh nbr u klosterbier Lakkalik ri Outback Lager Ipoh Coffee Laughing Lumberjack Lager Chang Chai Condiments Original Frankfurter gr ne Sohe Sirop d rable Chef Anton s Gumbo Mix Northwoods Cranberry Sauce Grandma s Boysenberry Spread Chef Anton s Cajun Seasoning Aniseed Syrup Louisiana Hot Spiced Okra Wegie spread Louisiana Fiery Hot Pepper Sauce aula Malacca genen Shouyvu Creating groups Adding a group into a report can be done by using two methods First method you add the Group header band in the Configure Bands window To do this press the Add button and select the Group header band FastReport adds the group to the available Data band or will create a whole group if such a band is not in the report Report creation 97 Contigure Bands Report Title Name GroupHeaderl rere oroup Header Bookmark Border Border 225 Group Footer CanBreak False Cangrow False CanShrink False Condition Cursor Default Evenstyle EvenStylePriority Use ill Fill Solid Height icm Hyperlink Hyperlink a SH P C l Mame The object s name In order to configure a group double click the Group header band You will see the group header editor window Edit Group Group condition
194. ou can highlight even rows or columns with other color We will use the Example 2 to show how to do it Select the whole area of matrix data as it is shown in the figure Employee Year Month Mame Total year Month Revenue ear Total Total Call the conditional highlighting editor Add the following condition Matrix1 RowIndex 2 0 and choose background color a little darker than the previous one In this example Matrix1 is a name of our matrix The RowIndex property of the matrix returns the number of the current printed line For column highlighting use the matrix ColumnIndex property in the same way When we run the report we will see the following Erniplowee Year Month Andrew Fuller Janet Leverling Wancy Dayolio Steven Buchanan Total 2 1 000 00 41 000 00 10 1 300 00 3 000 00 4 900 00 1999 11 2 000 00 3 100 00 1 100 00 6 200 00 12 1 200 00 1 200 00 Total 3 900 00 6 100 00 3 300 00 0 00 13 300 00 1 1 300 00 3 999 00 5 299 00 2 2 100 00 1 400 00 3 500 00 P 3 3 200 00 3 200 00 Total 2 100 00 3 200 00 z 700 00 3 999 000 11 999 00 1 4 000 00 4 000 00 ITEA 2 1 500 00 4 100 00 5 600 00 3 1 600 00 1 600 00 Total 0 00 0 00 3 100 00 5 100 00 11 200 000 1 1 800 00 1 700 00 43 500 00 A Total 1 500 00 0 00 1 700 00 0 00 3 500 00 Total 7 600 00 9 300 00 10 800 00 12 099 000 39 999 000 Report creation Example 6 Using Expressions In
195. output file Export to PDF Page range All Information Current page Ores ST Enter page numbers and or page ranges separated by commas For example 1 3 5 12 Export Viewer Options Compressed Background Embedded Fonts Print Optimized Open after export Export parameters e Compressed output file is compressed It reduces file size but increases export time e Embedded fonts all fonts used in a report will be included into PDF file This will Significantly increase the file size e Background the page watermark will be exported as an image This will significantly increase the file size e Print optimized output of all graphics objects such as pictures charts in high resolution for further printing On the Information tab you may fill in the document information fields Preview print export 291 Export to PDF Document Information me O morman ter Td sse ooo emos O Producer FastReport NET Open after export Export to PDF Viewer Preferences Hide toolbar Hide menubar Hide window user interface L_ Fit window Center window Print scaling Open after export Export to Word RTF RTF Rich Text Format was developed by Microsoft as a standard format for exchanging text information At the moment RTF documents are compatible with many new text editors and operation systems Export method tabular When exporting to RTF there w
196. oxes 9 50 As seen on the picture the title of the tab is set to the hyperlink s value In our case this is the numeric value contained in the CategoryID data column This appears not informative and not beautiful Let s change our report to use the category name instead of its number For this do the following In the detail report e change the parameter s DataType property to the String e add the Categories data source into the report It will be used for referring to the Category Name column when filtering data e change the filtering expression of the Data band Products Categories CategoryName SelectedCategory In the main report e change the hyperlink settings Now we will pass the Categories CategoryName value into the report parameter If we run the report now we will see that the title of the tab is set to category name We can improve the detailed report a little Add the Text object which will print the name of the chosen category in the report title Report creation 155 oh Print E H Save j a 100 Interactive masterreport Confections Product Same Chocolade Gumba r Suroimibarchen Maxilaku Muuga WuG Nougat Creme Pavlova Schoggi Schokolade Scottish Longbreads Sir Rodney s Marmalade Sir Rodney s Scones Tarte au sucre Teatime Chocolate Biscuits valkoinen suklaa Zaanse koeken Eai P a a al Quantity Per Unit 10 pkgs 100 250 g bags 24 50
197. oxl TextBox ShortcutsEnabled false Help on properties and methods of the controls can be accessed from the MSDN Data filtering Dialogs can be used to filter the data which is printed in a report For example you have a report which prints a list of all the employees By using a dialog you can choose one or several from it and then when building the report the data is filtered so that only the chosen employees can be shown For using the data filtering it is necessary that the initial report contains all the data The name filtering itself assumes that unnecessary data will not be printed when building the report The simplest method for organizing data filtering is to use the Filter property on the Data band In the band editor you can indicate the filter expression for example 270 Dialogue forms Edit DataBand Data source Filter expression Sort Filter By using the dialogue you can ask a value froma user and use it in the filtering expression Look at the Simple filter example in the Examples section This method can be used if a simple value is needed If the task is to display a list of values and inquire one or several from it implementing this becomes difficult You may think that it is a simple task showing a list of employees in the ListBoxControl control element and choosing one or several values For implementing this you need to use the script which does the following get the data
198. perty is used with the RoundRectangle shape It allows to set the curve The Barcode object The object displays barcodes in the report It looks like this r q1 q4 edd 06 NYESO1 Eig The object supports the following types of barcodes Code Length Allowed symbols 2 of 5 Interleaved 0 9 2 of 5 Industrial 0 9 2 of 5 Matrix 0 9 Codabar 0 9 Code128 128 ASCII chars Code39 0 9 A Z Code39 Extended 128 ASCII chars Code93 0 9 A Z 40 Fundamentals Code93 Extended 128 ASCII chars EAN8 8 0 9 EAN13 13 0 9 MSI 0 9 PostNet 0 9 UPC A 12 0 9 UPC EO 6 0 9 UPC El 6 0 9 2 Digit Supplement 2 0 9 5 Digit Supplement 5 0 9 PDF417 any Datamatrix any QR code any A detailed description of different barcode types can be found in the internet for example here http www barcodeisland com Barcode data in an object is of a string type The string can contain any symbol allowed for the chosen type of barcode You can choose the type of barcode in the context menu of the Barcode object You can connect an object to data by using one of the following methods e set the barcode data in the Text property e bind the object to a data column using the DataColumn property e set the expression that returns the barcode data in the Expression property The Barcode object has the following properties Property Description Barcode This property contains barcode specific settings Expand this pro
199. perty to set these settings Angle This property determines the rotation of a barcode in degrees You can use one of the following values 0 90 180 270 Zoom This property allows to zoom a barcode It is used along with the AutoSize property AutoSize If this property is on the object will stretch in order to display a whole barcode If this property is off the barcode will stretch to to object s bounds ShowT ext This property determines whether it is necessary to show the human readable text Fundamentals 41 DataColumn Expression Text Padding The data column which this object is bound to The expression that returns the barcode data The barcode data The padding in pixels The following properties are specific to the barcode type To change them select the barcode go Properties window and expand the Barcode property Property WideBarRatio CalcCheckSum AutoEncode AspectRatio 42 Description This property is specific to all linear barcodes It determines the wide to narrow bar ratio For most of barcode types the value for this property should be between 2 and 3 This property is specific to all linear barcodes It determines whether is necessary to calculate the check sum automatically If this property is off you should provide the check digit in the barcode data This property is specific to the Code128 barcode This code has three different encodings A B C You should either set t
200. pression Hyperlink to URL Products Product arrne WIM Fask repore comm Set up the bookmark we navigate to when clicking on an element in the TOC For this select the first Data band and indicate the following expression in its Bookmark property Categories CategoryName To set up the report outline do the following e select the first report page This can be done by switching to the page e in the Properties window set the following value to the OutlineExpression property Contents e switch to the second report page e select the first Data band and set its OutlineExpression property Categories CategoryName e select the second Data and set its OutlineExpression property Products ProductName Report inheritance Often we have many reports with the same data in it for example same header footer with company logo and some data email address etc Now imagine the situation that you need to change some company data for example email You have to do this in each report To avoid this you can use report inheritance What is it For example you have some common elements in each report logo company name email etc These elements are typically placed on the report title and or page header You can create a base report that contains only common elements All other reports will use base report and thus will contain such common elements plus own elements defined in a report In case you need to
201. previous examples we created matrix by dragging columns from the Data window You can also use expressions for this purpose In order to insert an expression into a matrix do the following e add any element from Data window into matrix It can be any element for example a system variable Date we just use it to create a matrix element e double click the element and select the needed expression in the expressions editor window If your matrix has expressions instead of data field you have to check that the matrix DataSource property was set up correctly When working with data columns this property is filled automatically when you drag a column onto a matrix Let us consider an example on how to use expressions For this we will use the Order Details table as a data source which contains a list of sold products grouped by employees There are several relations in this table which gives an access to the name of an employee product name and its category Our matrix will show each employee s sales categorized by products In order to build the matrix do the following e add the Order Details Products Categories CategoryName data column to the column header e add any item to the row header in order to create a matrix element Then set the following expression for the header element Order Details Orders Employees FirstName Order Details Orders Employees LastName e add any item to data cell in order to creat
202. previous method it does not get converted into a default value and may be null Returns the reports parameter with the indicated name Name can be compounded when referring to the nested parameter MainParam NestedParam Returns the value of the report parameter with the indicated name Sets the value of the report parameter with the indicated name Returns the value of the system variable for example Date Returns the value of the total defined in the Data window by its name Returns the data source defined in the report by its name The Engine object is an engine that controls the report creation By using the methods and properties of the engine you can manage the process of placing bands onto the page You can use the following properties of the Engine object Property te kee i ee late Eloa TOUY Lnr Gib Croll Dinca Description Current coordinates on the X axis This property can be assigned a value so as to shift the printed object Current printing position on the Y axis To this property a value can be assigned so as to shift the printed object Number of the current column in a multicolumn report The first column has the number 0 Script 255 int CurPage Number of the page being printed This value can be received from the Page system variable float PageWidth Width of the page minus the size of the left and right margins float PageHeight Height of the page minus the size
203. print the row 1 with all its columns Tablel PrintRow 1 Tablel PrintColumns insert page break before the row 2 Tablel PageBreak print the row 2 with all its columns Tablel PrintRow 2 Tablel PrintColumns As a result we get the following Report creation 121 Example 8 Printing totals We will look at the use of the total function in Example 6 We will modify it in the following way The cell Cella which we Zodie Res Unit Price Units In Stock ee Products ProductWame Products UnitPrice Products UnitsInStack Total Sum Cell8 Summary value If we run the report we will get the following Outback Lager i 15 2 Rh nbr u Klosterbier 125 Lakkalik ri 57 Original Frankfurter gr ne Sohe 32 Total 3119 122 Report creation Matrix type reports The Matrix object is a variety table and like the Table object is made up of rows columns and cells At the same time it is not known before hand how many rows and columns will be in the matrix this depends on the data to which it is connected The object looks like this When printing the matrix fills up the values and grows up and down The result can be as follows A few theory Let us look at the elements of a matrix Da fat a2 as a Pb fet 62 ea bs In the figure we see a matrix with 2 rows and 4 columns Here a b row header 1 2 3 4 column header al a4 b1 b4 cell
204. r code to add a value Let us show how to create a matrix which will print a 10x10 table of the following kind 1 2 3 1 1 2 2 3 3 Do the following e add an empty matrix into the report e put any element from the Data window into the row column and cell of the matrix Then call expression editor by double clicking the matrix element and clear an expression e clear the DataSource property of the matrix These steps are required to create a dummy matrix which has one row column and cell As a result the matrix will be as follows Total 140 Report creation Now create a ManualBuild event handler For that select the matrix go Properties window and press the 7 button Double click the ManualBuild event and FastReport will create an empty event handler Write the following code in it private void Matrixl ManualBuild object sender EventArgs e Our matrix has one level in row column and cell Create 3 arrays of object type each with one element per number of levels object columnValues new object 1 object rowValues new object 1 object cellValues new object 1 ror int i 1 a s 1U 1 4 Filling arrays columnValues 0O i rowValves 0 a cellValues 0 i Adding data into the matrix Matrixl AddValue columnValues rowValues cellValues In a handler you should use the AddValue method of the Matrix object in order to fill it with data This
205. r example 1 5 5 12 Options Wy Silay Page breaks Open after export Export parameters e Wysiwyg the result will be as close to the report as possible If this option is disabled FastReport will reduce the number of rows and columns in the resulting file e Page breaks enables page breaks in the resulting file Appearance and size of the resulting file depends on the report template see the Recommendations on report development section Export to PowerPoint 2007 PowerPoint 2007 is an application for working with electronic presentations It is included into Microsoft Office 2007 Export method is a layered one When exporting to PowerPoint there will be a dialogue window for setting parameters of the output file Preview print export 297 Export to PowerPoint 2007 Page range all O Current page Enter page numbers andfor page ranges separated by commas For example 1 5 5 12 Options Pictures Open after export Export parameters e Pictures select the format of pictures in the resulting file Export to OpenOffice Calc OpenDocument Format ODF OASIS Open Document Format for Office Application was designed by OASIS and based on XML format used in OpenOffice FastReport supports export to table ods file These files can be opened in OpenOffice Export method tabular When exporting to OpenOffice Calc there will be a dialogue window for setting parameter
206. r operations Adding filter into a report Filtering on data range Filtering on related data column Filtering using cascading lists Controlling the filtering from code Examples Example 1 Hello FastReport Example 2 Ask for a text from the user Example 3 Handling dialogue controls Example 4 Handling report objects Example 5 Simple filter Example 6 Automatic filtering Example 7 Automatic filtering by range Example 8 Filtering by related data column Chapter VilPreview print export Editing the report Printing the report Exporting the report Saving in FPX format Export to Adobe Acrobat PDF Export to Word RTF Export to HTML Export to MHT web archive Export to Excel XML Export to Excel 2007 Export to PowerPoint 2007 Export to OpenOffice Calc Export to CSV Export to TXT Export to picture Export to FTP Export to Dropbox Export to Google Drive Export to SkyDrive Report design recommendations Sending the report by email Table of contents 270 270 2 1 2 2 273 214 214 214 2175 275 275 276 2 7 278 279 280 281 282 286 28 288 290 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 306 307 309 Fundamentals Fundamentals In this chapter we will learn the principles of working with a report in the FastReport We will also take a close look at report elements such as report pages bands and report objects The report The report building process can be repre
207. re are calculated automatically Configuring the matrix After you have placed a new Matrix object on a sheet it will be as follows Drag data here to create anew column Drag data hereto Drag data hereta Create a new row create a new cell Matrix can be configured with the help of the mouse To do this drag and drop data source columns from the Data window onto the matrix to create rows columns and cells The matrix highlights a red frame to a place where the new data will be placed 124 Report creation Actions e i Data Sources Drag data hereto 5 B J MatrixDemo create a new column Drag data here ta Drag da Shere to Ls A FESE Create afew cell temr IET a hs ItemsSold 2 Revenue If the matrix contains some elements already then when placing a new element an indicator will be shown In the given case the new data will be placed between the Year and Name elements Drag data here to Year Mame create a new column Namel rear Liiu st Brag daka here ko create 4 new cell otal You can also change the order of the existing elements To do this click on the element s border shown with black and drag it to the needed place Year Month 9 Ware Drag dat q creatdaenew cell Year To delete an element select it with the mouse and press the Delete key Report creation 125 Configuring headers To configure the hea
208. report have got By using the Add Bookmark method you can add a bookmark programmatically This method creates a bookmark on the current page at the current printing position The GetBookmarkPage method returns the page number on which the bookmark is placed This method is often used when creating the table of contents for displaying page numbers In this case the report must have a double pass Reference to data sources Contrary to the FastReport expressions covered in the Expressions section never use Square brackets in script for referring to the data sources Instead of this use the GetColumnValue method of the Report object which returns the value of the column string productName string Report GetColumnValue Products Name As seen you need to indicate the name of the source and its column The name of the source can be compound in case if we are referring to the data source by using a relation Details about relations can be found in the Data chapter For example you can refer to a column of the related data source in this way string categoryName string Report GetColumnValue Products Categories CategoryName For making the work easier use the Data window From it you can drag data elements into the script during this FastReport automatically creates a code for referring to the element For referring to the data source itself use the GetDataSource method of the Report object DataSourceBase ds R
209. rinted Each cell of the matrix has got its own address This is a combination of the values from the column and row headers In our example the address of the cell is a combination of the year and name of the employee Exactly this data can be passed to the detailed report How can this be done Very simple set the hyperlink showing only the report name and name of the parameter Parameter values do not need to be indicated for a matrix cell FastReport itself forms the value and passes it into the parameter Assuming that we have clicked on the top left cell containing the number 3900 This is the sum of the sales of the employee named Andrew Fuller for the year 1999 What form is used to pass this value into the parameter FastReport combines column and row values by using a separator 1999 Andrew Fuller Does it mean that we must extract the value of the year and the name of the employee from this string convert the year into the int and use these values for data filtering No it s much 158 Report creation simpler All that we need to do is to create a parameter that has nested parameters You can learn about this in the Data chapter In the given case parent parameter can be like this TE Parameters Sly Selectedcell B Year BI Mame When creating the parameter consider the following moments e you don t need to set up the parent parameter Just give it the name e a parent parameter must have as many nested paramete
210. rix cells In this example we used conditional highlight which depends on cell value itself Besides you Report creation 133 can highlight a cell depending on values from matrix headers We will show by the following example how to highlight cells which are belongs to 2000 year in red For this select matrix cells as shown in the figure below Set the following highlight condition int Matrix1 RowValues 0 2000 In this case Matrix1 is a name of our matrix The RowValues property of the matrix has got an object type and contains an array of values from the row header of the current printed row Number of values in array is equal to number of levels in a header There are two values in our example the first one is Year and the second one is Month Do not highlight the last row RowValues property has an undetermined value for it and will cause an error when building the report When we run the report we will have the following result 3 900 00 6 100 00 3 300 00 0 00 41 300 00 3 999 000 2 100 00 1 400 00 43 200 00 2 100 00 3 200 00 2 700 00 3 999 00 You can also use matrix s ColumnValues property for column values reference 1 eS t4 300 00 Wie iee am h T md B M al p a a i Ln T le m mm tE e UL pt 5 299 00 3 500 00 3 200 00 11 999 00 n d a 4 Report creation Example 5 Highlighting even rows To improve the appearance of a matrix y
211. rosoft com mschart Let us highlight some features of Microsoft Chart e more than 30 types of series bars columns areas lines bubbles pie circular financial pyramidal ranges e 3D support e supports several series of different types in one chart e full control over appearance and behavior of each chart element Chart elements Microsoft Chart consists of the following elements Chart area Series Title Series label Legend Simple chart DS Seriesi Axes Marker Axis label Grid Border and fill of the object One chart may have one or several chart areas One chart area may contain one or several series Below you can see the chart which contains two chart areas the first area contains two series the second area contains one series 166 Report creation Advanced chart 3 MS Seriesi 3 ae 2 5 Series 2 ie A Ia E E 0 5 Some series for example pie series require exclusive chart area Chart editor The Chart object contains numerous settings which can be handled in the chart editor To invoke the editor double click the Chart object Report creation 167 Chart and its Handling series Editing selected element series chart or series Chart Ec itor iem io ptt up ith Poet Beg mene Series2 Line Example Its elements are Clickable Handling series The Chart object can contain one or several series Series list is displayed in the editor Click an item to set up its
212. rows the data band will be printed together with all its related bands data header data footer e if the data source is empty only the child band with No data to display text will be printed Printing hierarchy A Data band allows printing a hierarchical list For this one band and one data source are used Hierarchy must be defined in the data source with the help of two data columns 1 Key column This is the data row identifier 2 Column which contains the key of this item s parent In order to print such a source in a hierarchical form you need to set the following Data band properties This can be done in the Properties window El Hierarchy Id olurnin Indent 1 cm ParentidColurnn e indicate the key column in the IdColumn property e indicate the column containing parent value in the ParentIdColumn property e indicate the hierarchy indent in the Indent property Let us look at an example of how to print a hierarchy of employees from the Employees demo table The table has got two columns which we need e EmployeeID column is the key and contains the employee ID e ReportsTo column contains the ID of parent employee Create a report that looks like the following EMPLOYEE HIERARCHY Report Title Employees FirstWame Employees LastName TEmplovees Title L al Set the Data band properties which is responsible for the hierarchy in the follow
213. rs as there are values passed from the matrix In the given case there are two values e order of the nested parameters must correspond with the order of the values passed from the matrix In our case the year will be passed in the first parameter and the employee name will be passed in the second parameter e nested parameters can be named as you wish but it is better to give them names which correspond with the names of the matrix elements e it is very important to set the data type for every nested parameter correctly Data type must correspond with the value which is passed into the parameter In our case the first parameter Year must be an integer type and the second employee name String After we have clarified all the needed things we will create the report Select the cell of the matrix and call the hyperlink editor Year Employee Tear Total Mame Total Edit Format w Hyperlink EI EJ Function O Delete In the hyperlink configuration indicate the parent parameter as a report parameter in our example SelectedCell Report creation 159 Edit Hyperlink URL Report page Page number a Pages Report parameter Bookmark Saos SeleckedCell yt Report Specify 4 parameter value Report page Eee or enter the expression that returns a parameter value Custom fr What will happen if you click this object in the preview window Specified page will be
214. rt structure by adding the needed bands into the report 3 Connect the band to a data source 4 Place the Text objects on the bands to print data 5 Setup the appearance formatting 56 Report creation Choosing data for a report Before you start building a report you need to choose the data which will be printed in the report You can do this in two ways e you can choose one of the data sources which was registered in the report by a programming method This can be done in the Data Choose Report Data menu by marking the needed data source Choose Report Data Select data sources and Fields that vou wank to use in the report E Categories EJ Customers E Employees 4 Order Details E Orders E ME Products _ E Shippers JES Suppliers EJ MatrixDemo EJ Categories BusinessObject Show aliases Cancel e you create a new data source in the Data New Data Source menu Read more about data sources in the Data sources chapter Just after you have chosen the data source it appears in the Data window Now you can use this source in the report Many reports use only one data source For reports of master detail type you need to choose two data sources related to each other you can read more about relations in the Data sources chapter Several data sources can also be needed in a report which prints data from related sources Report creation 57 Dynamic layout
215. s As you can see the Products data source is contained within its parent Categories BusinessObject E a Data Sources B E Categories BusinessObject LA Name A Description E E Products A Name UnitPrice This means that these two data sources are related to each other and can be used in the master detail report type You can also use each of these data sources separately ina simple list report type 200 Data Relations Between two data sources a relation can be set The relation is used to define the master detail relationship For example one record in the Categories table can have multiple entries in the Products table Categories LategoryID g oaar 7 name Products i aa T a ee p In order to create a relation you need to indicate the following Parent table Child table Set of key columns in the parent table Set of key columns in the child table As an example we will look at Categories and Products tables from the demo database They have the following structure Categories lz Products P Category IO T ProductID Category Mame ProductName Description Supplier ID Picture CategoryID A CategoriesTableAdapter QuantityPerUnit UnitPrice UnitsInStock UnitsOnOrder ReorderLevel Discontinued EAM 13 ProductsTableAdapter Both tables have got the CategoryID field on which the relationship can be set So one category may contain se
216. s In order to build such a report only one data source will be needed which has got 3 columns and contains the following data al a2 a3 a4 bi b2 b3 b4 OOOO Wa a a YW RWNRFAWNE As seen the first column represents the matrix row the second matrix column and the third contents of the cells at the intersection of rows and columns with the indicated number When creating a report FastReport creates a matrix in the memory and fills it with data During this the matrix dynamically increases if the row or column with the given number doesn t exist yet Report creation 123 A header can have more than one level Let us look at the following example In this example a column is compound that is it has got two values This report requires the following data a 10 1 al0 1 a 10 2 al0 2 a 20 1 a20 1 a 20 2 a20 2 b 10 1 b10 1 b 10 2 b10 2 b 20 1 b20 1 b 20 2 b20 2 Here the first column represents the row the second and the third represent the matrix column The last data column contains the value of the cell The next matrix element subtotal and grand total the next figure demonstrates it Ca a0 a02 a010 201 2202 82014202 sumta ef bio e02 b0 b201 202 e20 1202 surte Tad al0 1 a10 2 a10 1 b10 1 az20 1 a20 2 a20 1 b620 1 9 surmfai b10 1 b10 2 ja10 2 b10 2 b20 1 b20 2 a20 2 b20 2 sumi by This report is built on the same data used in the previous example Rows that shown grey in the figu
217. s Width Height This property determines how the object will be changing its position and or its size when the container on which it is laying grows or shrinks By using Anchor it can be done in such a way that the object expands or moves synchronously with container Read more about this property in the Dynamic layout chapter This property determines on which side of the container the object will be docked Read more about this property in the Dynamic layout chapter These properties control the object s border and fill They can be changed using the Border and Fill toolbar These properties allow fitting the height of the object in such a way that it fits the whole text Read more about this property in the Dynamic layout chapter An object whose property is enabled will be moving up and down if the object above on can either grow or shrink Read more about this property in the Dynamic layout chapter An object whose property is enabled will be stretched to the bottom of a band Read more about this property in the Dynamic layout chapter Objects Text and Rich Text have this property It determines whether the object s contents can be broken into parts This property determines on which pages the object can be printed Read more about this property in the Booklet type report chapter This property determines the type of mouse cursor when it is located over an object The property works onl
218. s into it Data elements can be inserted into the Text of the expression text drag amp drop or double click it Edit Expression Products gProductName substring O0 1 SI 5 6 Products ProductID A Productarne 42 SupplierID liz CategoryID QuantityPerUnit UnitPrice UnitsInStock 2 UnitsOnOrder 42 ReorderLevel i Discontinued EAN1S Reference to report objects For referring to report objects use the object s name The following example will return the height of the Text1 object Text1 Height For referring to report properties use Report variable The following example returns file name from which a report was loaded Report FileName Expressions 243 Besides you can refer to nested object properties The following example will return a report name Report ReportInfo Name Using Net functions You can use any Net objects in expressions The following example demonstrates Max function use Math Max 5 10 By default a report uses the following Net assemblies System dll System Drawing dll System Windows Forms dll System Data dll System XmIl dll You have access to all Net objects declared in these assemblies If you need to have access to another assembly add its name in report assemblies list You can do it in the Report Options menu by choosing the Script element in a window Referenced assemblies System all System Drawing all System Windows Forms
219. s of the output file Export to Open Office Calc Page range all Current page Enter page numbers andfor page ranges separated by commas For example 1 5 5 12 Options Wysiwyg Page breaks Open after export 298 Preview print export Export parameters e Wysiwyg the result will be as close to the report as possible If this option is disabled FastReport will reduce the number of rows and columns in the resulting file e Page breaks enables page breaks in the resulting file Appearance and size of the resulting file depends on the report template see the Recommendations on report development section Export to CSV The CSV file is used for the digital storage of data structured in a table of lists form Each line in the CSV file corresponds to a row in the table Within a line fields are separated by commas each field belonging to one table column CSV files are often used for moving tabular data between two different computer programs for example between a database program and a Spreadsheet program Export method tabular When exporting to CSV there will be a dialogue window for setting parameters of the output file Export to CSV Page range all OC Current page Enter page numbers andfor page ranges separated by commas For example 1 3 5 12 Options Separator ls Codepage Default ka Data only Open after export Export parameters e Separator the fi
220. se the justify align or non standard line height The Rich Text object This object displays the formatted text in the RTF format It looks like this Dear Customers Contact ame We disturb you to inform that new version of FastReport is available for downloading at www fastreport com Notices suggestions and bug reports are welcomed With best regards Fast Reports team Try to use the Text object to display a text When you export the report to some document formats the Rich Text object will be exported as a picture This object supports only the solid fill type Gradient hatch glass fills are not supported To edit the object double click on it You will see the editor window 34 Fundamentals RichText Editor ga amp tatoma BSF Use Dear Customers ContactName pw j j a Data Sources System Variables E We disturb you to inform that new version of FastReport is available for downloading at www fast reportcom Notices suggestions and bug reports are welcomed With best regards Fast Reports team You can also use the Microsoft Word to create a text When you have done save the text in the RTF format Next you need to open the Rich Text editor and load the RTF file into it by pressing the 5 button The Rich Text object does not support all of the Microsoft Word formatting features You can display a data in this object the following ways e you can insert an
221. sender EventArgs if Int32 Report GetVariableValue Row 2 0 Datal FillColor Color Gainsboro The Row system variable returns the number of the row of the printed band In order to insert into the script a reference to the variable drag it from the Data window During this in the script a string will be inserted Int32 Report GetVariableValue Row If we run the report we will see that even rows will be highlighted in light gray color Chai 18 00 Chang 19 00 4niseed Syrup 10 00 Chef Anton s Cajun Seasoning 27 00 Chef Anton s Gumbo Mix 21 35 The same effect can be achieved with the help of the EvenStyle property of the Data band You can read more about this in the Highlight odd even data rows section of the Report creation chapter Example 3 Data filtering In this example we will show how to hide the Data band row depending on the given conditions We will be using e BeforePrint band event e reference to the data source froma script 262 Script Create a simple report having the following appearance Products ProductMame Products UnitPrice Create a BeforePrint event handler for the band private Void Datal BelorePrint objee sender EventArgs amp if Decimal Report GetColumnValue Products UnitPrice gt 20 Datal Visible false In the given case the band rows which have the unit price gt 20 will be hidden Chai 18 00 Chang
222. sented as follows Report Preview Print template i gt t Report Prepared engime report 2 R The Data Export Send by email 3 R Report template later Report this is what we see in the designer Reports are saved in files with an extension FRX A Report can be created with the help of designer or programmatically Data can be any this is data defined in the program or data from DBMS for example MS SQL FastReport can also work with business logic objects later business objects Prepared Report this is what we see in the preview window Prepared report can be previewed printed saved in one of the supported formats doc xls pdf and others or can be sent by email Report designer In order to create a report template a report designer is used A designer gives the user comfortable facilities for designing the report and allows previewing the report at the same time The report designer is the compound part of FastReport and does not depend on the development environment for example MS Visual Studio If you are a software developer you may include the report designer into your application This will give your end users the ability to either change the existing report or create a new one 12 Fundamentals Toolbars The bands structure Menu Bands and report objects The report script EMPLOYEES LEMpPIOyees rirsowame Fmnlovees astName l Birth date Employees BirthDate
223. series If you choose the Chart object from the series list you will see the following property pages Report creation 169 Data Appearance Chart area Ames Legend Title Template Series palette BrightPastel w Back color White k Secondary color Gradient Hatch style Border skin Border color Border style Border width 2 4 Appearance border and fill of the chart Chart area border fill shadow 3D 3D settings Axes setup appearance of axis its title labels grid markers custom labels and strips Legend style of legend docking border fill shadow and font Title style of title docking border fill shadow font If you choose the series object from the series list you will see the following property pages 170 Report creation Data Values Back color Transparent mla borde ratchet Labels Border color Transparent Markers Border width 1 2 Shadow color ee 128 0 0 0 w Shadow offset 0 2 Appearance some settings specific to the selected series type Fill amp border fill and border of the series values Labels series labels You can choose label type font color and fill Markers series markers You can choose marker type its color and border Connecting chart to data You can fill the chart with data in several ways 1 Use data source To do this you need to indicate the data source for the Chart object and
224. sets Start color Middle color End color The Auto mode may be suitable in most cases 186 Report creation When a color scale is set up an indicator control is displayed in the bottom part of the Map object 4017 12050 0 8033 To set the appearance and position of the indicator select the Map element in the layers tree control and switch to the Color scale tab General Visible Color scal Hide if no data General Highlighting data using size When using layer type geodata from an application the data is displayed as a small circle with a caption The size of the circle can be bound to the data in the same way as highlighting data using colors To do this set up the size ranges on the Size ranges tab Report creation 187 Data Appearance Color scale Size ranges Labels start size End size Number of ranges Start End Auto Auto Auto Auto Auto Auto Size Auto Auto Auto The size ranges have the following properties min value max value and size in pixels You can use as many ranges as you need Set the number of ranges first and then set the properties for each range By default all range properties are set to Auto meaning FastReport calculates the minimum and maximum values for each range automatically The auto size is chosen from two presets Start size End size The Auto mode may be suitable in most cases
225. sions and values The Switch function evaluates the odd numbered expressions from lowest to highest index and returns the even numbered value associated with the first expression that evaluates to True Example returns one of the following values a greater than 0 a less than 0 a equals to 0 depending on a value Swit h a gt 0 a greater than 0 a lt 0 a less than 0T a 0 a equals to 0 Totals In many reports we may need to show some total information sum of the group number of rows in the list and many others FastReport uses totals to perform this task For the total you need to indicate the following parameters e The total function type e The expression which is supposed to be calculated For the Count function you do not need to indicate the expression e The condition The function will be calculated if the condition is met It s not obligatory to set up the condition e The data band for which the function will be processed e The band in which the total value will be printed The list of total functions is given below Function Description Sum Calculates the sum of the expression Data 233 Min Max Average Count Creating a total Calculates the minimum value of the expression Calculates the maximum value of the expression Calculates the average value of the expression Returns the number of rows We will look at using the total function as an example Le
226. source columns Group printing is done in the following way 1 group header is printed 2 data row is printed 3 checks if the grouping condition has changed 4 if the condition has not changed next data row is printed p 2 5 if the condition has changed the group footer is printed and starts printing a new group p 1 Assuming that we have a Products table with the following data Report creation 95 LategoryName Beverages Beverages Beverages Beverages Beverages Beverages Beverages Beverages Beverages Beverages Beverages Beverages Condiments Condiments Condiments Condiments Condiments Condiments Condiments Condiments Condiments Condiments Condiments Condiments ProductName Cote de Blave Chartreuse werte Steeleye Stout Guarana Fant stica Sasquatch Ale Rh nbrau Klosterbier Lakkalik ri Outback Lager Ipoh Coffee Laughing Lumberjack Lager Chang Chai Original Frankfurter gr ne Sohe Sirop d rable Chef Anton s Gumbo Mix Northwoods Cranberry Sauce Grandma s Boysenberry Spread Chef Anton s Cajun Seasoning Aniseed Syrup Louisiana Hok Spiced Okra Vegie spread Louisiana Fiery Hot Pepper Sauce Gula Malacca genen Shouvu Data can be grouped on the CategoryName column This column will be printed in the group header The data itself is presented by the ProductName field The report will be as follows Group Header Category Nene Products Categories Categ
227. splays the hour in the range 1 12 If the hour is a single digit 1 9 it is formatted with a preceding O 01 09 Displays the hour in the range 0 23 If the hour is a single digit 1 9 it is displayed as a single digit Displays the hour in the range 0 23 If the hour is a single digit 1 9 it is formatted with a preceding O 01 09 Displays the minute in the range 0 59 If the minute is a single digit 0 9 it is displayed as a single digit Displays the minute in the range 0 59 If the minute is a single digit 0 9 it is formatted with a preceding O 01 09 Displays the month measured as a number between 1 and 12 inclusive If the month is a single digit 1 9 it is displayed as a single digit Displays the month measured as a number between 1 and 12 inclusive If the month is a single digit 1 9 it is formatted with a preceding O 01 09 Displays the abbreviated name of the month Displays the full name of the month Displays the seconds in the range 0 59 If the second is a single digit 0 9 it is displayed as a single digit only Displays the seconds in the range 0 59 If the second is a single digit 0 9 it is formatted with a preceding O 01 09 Displays the first character of the A M P M designator Displays the A M P M designator Displays the year as a maximum two digit number The first two digits of the year are omitted If the year is a single digit 1 9 it is displayed as a single digit
228. ssary to set up formatting for cells After that the matrix will be as follows Report creation 131 Run the report and you will have the following result Example 3 Printing the name of the month In the previous example there were numbers of months printed in a matrix This occurred because the Month data column contains the number of the month not its name In order to print the name of the month do the following e choose a cell where the number of the month is printed In our case it is a cell with a name Cell8 e in the Property window press the d button and double click BeforePrint event e FastReport will add an empty event handler in the report script Write the following code Pravace void Cells BerorerPrint object Sender Even LArgs e string month Names new string Jeilery rebru uary Maren April May June July August September October November December Cell8 is a cell that prints the month number Cell8 Value is a value printed in the cell i e the month number This value is of System Object type so we need to cast it to int Cell8 Text monthNames int Cell8 Value 1 When you run the report you will have the following result 132 Report creation Wear Month Andrew Fuller Janet Lever February r October 1 900 00 pen 1999 Movember 42 000 00 December 7 Total 3 900 00 January E February gm 2000 roo a
229. st double click on it You will see a text editor Edit Text Text H Text System Variables Text There is a data tree on the right side of the editor which elements can be added into the text This can be done by dragging the element onto needed place by using the mouse Another way to insert an element into the text double click on the element and it will be added onto the Fundamentals 29 Cursor s Current position In order to save the changes and close the editor window click the OK button or press the Ctrl Enter keys Another method of editing a text in place editing To do this select the Text object and press Enter To finish editing click somewhere outside the objects bounds or press Ctrl Enter Press Esc key to cancel the changes When editing an object in place its size can be changed by using a mouse Displaying the expressions The Text object can contain a plain text mixed with expressions For example Today is Date When printing such an object all expressions contained in the text will be calculated So the result may look like this Today is 12 09 2010 As seen expressions are identified by square brackets This is set in the Brackets property which by default contains the string When needed you can use a different set of symbols for example lt gt or lt gt In the last case an expression in the text will be like this Today is lt Date gt Apart from this
230. stReport NET preview The report can be exported to one of the supported formats before being saved to the Dropbox Before saving a report to a Dropbox an application must be created in your Dropbox account Do this by logging in to your Dropbox account and taking the following steps click the More button it is located at the bottom of the Dropbox homepage choose Developers in the drop down list you will be directed to the page for developers go to App Console it directs you to the list of applications click the Create App button the Dropbox will check your email click Send Email In your mail system inbox you will find an email having a Confirm button click the button to confirm your email address Finally you will be directed to Create a new Dropbox Platform app Select Dropbox API app and answer the question What type of data does your app need to store on Dropbox by selecting Files and datastores Answer the question Can your app be limited to its own private folder by choosing either of the two proposed answers This page also requires you to enter the name of the application After clicking the Create app button the system will create the application As a result the application settings page is opened Here you can see the App key and the App secret which are required when exporting to a Dropbox You can now go to the FastReport NET preview and export the fi
231. stReport there are 13 types of bands Depending on its type the band is printed in a certain place in the report Band Report Title Report Summary Page Header Page Footer Column Header Column Footer Data Data Header Data Footer Group Header Group Footer Child Overlay How it s printed It is printed once at the very beginning of the report You can choose the order of printing before the Page Header band or after it with the help of the TitleBeforeHeader page property Changing this property can be done with the help of Properties window By default property is equal to true that is report title is printed before page header It is printed once at the end of the report after the last data row but before the Page Footer band It is printed on top of every page of the report It is printed at the bottom of every page of the report This band is used when printing a multi columned report when the number of columns indicated in the page setup gt 1 It is printed on top of every column after the Page Header band Printed at the bottom of every column before the Page Footer band This band is connected to the data source and is printed as many times as there are rows in the source This band is connected to the Data band and is printed before the first data row This band is connected to the Data band and is printed after the last data row It is printed at the beginning o
232. t ID You can refer to such a data column in the following way Categories Product ID When referring to the data element you must use the alias if it has been defined Never refer to an element by using its original name in this case In order to rename a data element in this case choose it in the Data window and press F2 Also you can select a Rename item in the object s context menu After this enter the required name and press Enter You can also rename an element by using the Properties window Select an element in the Data window switch to the Properties window and change the value of the Alias property In order to delete an alias reset to the original name select an element and choose the Delete alias item in its context menu Hierarchical data sources The data sources we have looked at are relational that is they come froma relational DBMS often called RDBMS FastReport also supports other kinds of data the hierarchical data sources Such data sources come from so called business objects which are often used in applications to represent a relational data sources as a Net classes The only way to add a hierarchical data source in your report is to register it programmatically It will be discussed in the Programmer s manual Now we will look at some differences between ordinal and hierarchical data sources In the figure below you can see two data sources Categories BusinessObject and Product
233. t strike gt lt strike gt Strikeout text lt sub gt lt sub gt Subscript lt sup gt lt sup gt Superscript lt font color gt lt font gt Font color The color may be either the named color such as DarkGray or a hexadecimal code in the RGB format for example FF8030 The following examples demonstrate how these tags can be used text lt b gt bold text lt b gt lt i gt text in italic lt i gt lt b gt lt i gt bold and in italic lt b gt lt i gt E mc lt sup gt 2 lt sup gt A lt sub gt 1 lt sub gt B lt sup gt 2 lt sup gt this is regular text lt font color red gt and this is a red one lt font gt this is regular text lt font color FF8030 gt and this is an orange one lt font gt This text will be displayed in the following way text bold text textin italic bold and in italic E mc A this is regular text and this is a red one this is regular text and this is an orange one 32 Fundamentals Object s properties Property AllowExpressions Angle AutoShrink AutoShrinkMinSize AutoWidth Brackets BreakTo Clip Duplicates FirstT abOffset FontWidthRatio HideValue HideZeros Highlight HorzAlign VertAlign HtmIT ags LineHeight NullValue Fundamentals Description This property allows to turn on or off the expression handling It is on by default This property indicates the text rotation in degrees This property allows to shrink t
234. t us create the master detail report that uses two tables Categories and Products Categories CategoryName Product Name Units In Stock L l a E r T 1 Products ProductName Products UnitsInStack L p m The prepared report will be as follows Beverages Product Name Condiments Units In Stock Product Name Units In Stock Chai 39 4niseed Syrup 13 Chang 17 Chef Anton s Cajun Seasoning 53 Chartreuse verte 69 Chef Anton s Gumbo Mix T Cote de Blaye 17 genen Shou 39 Guarana Fant stica z0 Grandma s Boysenberry Spread 120 Ipoh Coffee 17 Gula Malacca 27 Lakkalik ri 57 Louisiana Fiery Hot Pepper Sauce 76 Laughing Lumberjack Lager gz Louisiana Hot Spiced Okra 4 Outback Lager 15 Northwoods Cranberry Sauce 6 Rhdnbrau Klosterbier 125 Original Frankfurter gr ne Soe a2 Sasquatch Ale 111 Sirop d rable 113 Steeleye Stout z0 Vegie spread z4 Let us add total in this report which will be printing the total quantity of units in stock for each category sum of UnitsInStock data column Total will be printed in the Data Footer band To print total value you need to create it first For this press Action button in the Data window and choose the New total item Another method right click the Totals element in data tree and choose New total menu item You will see the total editor window 234 Data Edit Total Total Total name Tokallinits
235. tReport s prepared report can be made interactive This means that it will react to the user s actions in the preview window You can use the following interaction e when clicking on the report object some kind of operation is performed For example you can run detailed report and show it in a separate window e preview window can show the report outline which can be used for navigating on the report Hyperlink Almost all report objects have the Hyperlink property Using this property you can define an object s reaction to the mouse click in the preview window When clicking such an object one of the following can occur navigate to the URL address send e mail execute any kind of system command navigate to the report page with the indicated number navigate to the bookmark defined in another report object run detailed report in a separate preview window custom action defined in a script Hyperlink configuration To configure a hyperlink select the object which you want to make interactive and right click on it In the context menu select the Hyperlink item The hyperlink editor window will open 144 Report creation Edit Hyperlink URL Specify an URL fexample htop Sai url corm http www Fast report com Page number or enter the expression that returns an URL Bookmark Report Report page Custom What will happen if you click this object in the preview window Specified URL wi
236. tch to the Data processing tab and select the group type X value Report creation 177 Data processing Group interva Group function Appearance Fill amp border On the second report page create the list type report e in the Data window create a new report parameter called SelectedEmployee e create the following report layout r 7 SelectedEmployee orders L 4 ReportTitle Page Header Name Year Month TtemsSold MatrixDemo Name MatrixDemo Year MatrixDemo Month MatrixDemo ItemsSold Total Totalltems Report Summary 4 e open the data band editor and indicate the following filter condition MatrixDemo Name SelectedEmployee Now set up the hyperlink of the Chart object e in the context menu of the Chart object select Hyperlink e choose the hyperlink type Report page e choose the second report page and indicate the parameter name SelectedEmployee The report is finished Run it and move the mouse to any chart value This value will be visually selected and the mouse cursor will change its shape Items sold Steven Buchanan 11 Nancy Davolio 12 Andrew Fuller 8 Janet Leverling 9 If you click the value you will see the following detailed report 178 Report creation Steven Buchanan orders Name Year Month ItemsSold Steven Buchanan 2001 1 3 Steven Buchanan 2001 2 4 Steven B
237. ted in two modes In the first printing mode bands and objects of the subreport are printed on the page of the main report There are some limitations e Subreport object must be located in lower border of the band e Never place other objects under the Subreport object When the report will be working such objects will be overlapping with the objects of the subreport Le Subreparti To place other objects under the subreport use the Child band Place the objects in the following way lg Subrepart1 L The second printing mode differs in that subreport s objects are printed on the band which contains the Subreport object You can enable this mode from the context menu of the Subreport object To do this select the Print on Parent item This mode does not put a limit on placing of the objects Apart from that in this mode a parent band can either grow or shrink depending on how much data has been printed in the subreport The only problem with the second mode is that there may be a lot of data in the subreport When printing it the parent band will have a big height In order to print such a band correctly it is required to break its contents CanBreak property The break algorithm does not provide 100 quality and in some cases it can lead to the displacement of objects 106 Report creation Side by side subreports By placing two Subreport objects side by side on the same band you can print two
238. ter bands is possible only if the Data band was selected beforehand There is also another way of configuring some bands This can be done from the Report menu 7 iT gm mm ai Report Title Report Summary Page Header Fage Footer Column Header Column Footer Fi T E Oyerlay Configure Bands Group Expert Styles Options To delete a band select it and press Delete key When configuring bands FastReport does not allow to do operations which leads to the creation of a wrong report template For example you cannot delete the Data band which is connected to the group for this the group needs to be deleted first Another example when deleting the Data band its header and footer are deleted automatically Also it is not possible to delete a band if it is the only one on the page Printing Bands So there are several bands placed on the page How will FastReport compose a prepared report Let us look at the following example Report Title Report Title Page Header Page Header E Er iI ili an Data Emplove Data Report Summary Report Summary Page Footer Page Footer The Report Title band will be printed first The Page Header band will be printed immediately after it Further the Data band will be printed as many times as there are rows in the data source to which the band is connected After all the rows of the Data band have been pri
239. th data When creating such a report the first page will be printed first then the second page and so on Every page of template can generate one or several pages of a prepared report this depends on the data it contains Prepared report a5 h E E Report pages are also used when working with subreports Contrary to other report generators subreports in FastReport are saved in a separate template page and not in a separate file Report template Apart from report pages a template can contain one or more dialogue forms Dialogue forms can be used for inquiring some parameters before creating a report Detailed work with dialogue forms will be covered in the Dialogue forms chapter 16 Fundamentals Managing pages When you have created a new report it already contains one page with several bands For a 2 cl adding a new page click the is button A page can also be added by clicking the te button and choosing New Report Page in the window Add New Item Report templates Blank Report Inherited Report Standard Report Wizard Label Wizard Report items s Mew Report Page New Dialog Form a Mew Data Source In a similar way dialogue forms can be added into the report For this use the button Template pages are displayed in the designer as tabs E Code E Pagel _ Pagez The first tab is t
240. times As a result we get the following jf Preinting 3 copies of Pow 1 and all of its columns for int is 0 2 lt 37 a4 Tablel PrintRow 1 Tablel PrintColumns printing row 2 and all of its columns Tablel PrintRow 2 Tablel PrintColumns Example 3 Printing the whole table from left to right private void Tablel Manualsbuild obieer sender As a result the following table will be printed which does not differ from the template printing column 0 and all of its rows Tablel PrintColumn 0 Tablel PrintRows printing column 1 and all of its rows Tablel PrintColumn 1 Tablel PrintRows printing column 2 and all of its rows Tablel PrintColumn 2 Tablel PrintRows Report creation EventArgs e 117 Example 4 Printing a table from left to right with a repeating column private void Tablel ManualBuild object sender printing column 0 and all of its rows Tablel PrintColumn Q Tablel PrintRows printing 3 copies of column 1 and all of its rows for int i 0 i lt Be 1 Tablel PrintColumn 1 gt Tablel PrintRows Printing column 2 and all of its rows Tablel PrintColumn 2 Tablel PrintRows EventArgs e In this example the middle column of the table gets printed 3 times As a result we get the following 118 Report creation Example 5 Printing a table with repeating rows and columns private void Tablel ManualBuild
241. to setup the conditional highlight Read more about this in the Formatting chapter These properties determine the text alignment Allows simple HTML tags in the object s text Read more about this property in the HTML tags chapter This property allows to explicitly set the height of a text line By default it is set to 0 so the default line spacing is used The text that will be printed instead of a null value You also need to uncheck the Convert null values option in the Report Options menu 33 Padding This property allows to setup the padding in pixels RightT oLeft This property indicates whether the text should be displayed in right to left order TabWidth This property determines the width of the TAB symbol in pixels Text This property contains the text of the object Text Fill This property determines the text fill Use this property editor to choose between different fill types Trimming This property determines how to trim the text that does not fit inside the object s bounds It is used only if the WordWrap property is set to false Underlines This property allows to display a graphical line after each text line This property can be used only if the text is top aligned WordWrap This property determines whether it is necessary to wrap a text by words Wysiwyg This property changes the display mode of the Text object to match the screen and the final printout This mode is also used if you u
242. ttons affect all lines of frame The button displays a dialog which allows to set up each line separately Border Editor Border Choose the line style and choose the line to apply the style Pte To work with fill there are two buttons on the toolbar The k button allows to choose a color for the solid fill type The button displays a dialog which allows to choose between different fill types 62 Report creation Fill Editor Colors Start Linear gradient End Path gradient _ Options Contrast Glass Text formatting To change the Text object appearance use the Text toolbar Conditional highlight Text color il iil A oa 2 Tahoma Font parameters Text alignment Text rotation Styles To set up the object appearance you may use styles Style is a set of the following properties border fill font text color The list of styles is stored in a report You can control it either from the Report Styles menu or by the Ae button in the Style toolbar Report creation 63 Style Editor Style settings Ji Text color sample You can set an object s style in the following ways e set the Style property in the Properties window e use the Style toolbar Call the style editor Select style Ad E Available styles If the toolbar is not present on the screen enable it in the View Toolbars menu When you set the object s style th
243. ty row is to fill the free space on a page In this case the Child band is attached to the bands of either the Data Footer or Group Footer types and fills the free space on the page The footer band will be printed at the bottom of the page 78 Report creation In order to print an empty row this way attach the Child band to the footer band and enable its FillUnusedSpace property You will see that the child band is now displayed above the band it is attached to In the figure below the Child band is attached to the Report Summary band Categories Category Name report summary Child Report Summary When we run such a report we will see the following ee report summary Printing No data text When the data band is connected to an empty data source it will not be printed Sometimes it is required to print some text like No data instead of just an empty page To do this e add a child band to the data band e set the child band s PrintIfDatabandEmpty property to true it can be done in the Properties window e put the Text object on a child band and write the No data to display text in it Page Header CompanyName Country Customers Company Mame Tcustomers Country L No data to display z mm Report creation 79 The report will be printed in the following way e if the data source has some data
244. uchanan 2000 1 4 Total 11 Report creation 179 Reports with maps The MapObject component is intended for displaying 2D maps in ESRI shapefile format You can find information on this file format at http en wikipedia org wiki Shapefile Two files are required shp shape format the feature geometry itself and dbf attribute format columnar attributes for each shape Map elements The Map object consists of the following elements Border Fill Polygon Label 401 12050 0 a Color scale indicator One Map object can display one or more layers Each layer contains its own map Controlling the map with the mouse In the report designer and in the preview window the map can be controlled by the mouse zoom in and out using the mouse wheel pan the map by dragging the left mouse button change a polygon s properties in the Properties window by clicking the left mouse button inside a map polygon 180 Report creation The minimum and maximum zoom values can be set in the MinZoom and MaxZoom properties These properties are changed in the Properties window The map cannot be controlled in the asp net report viewer The Map object editor The Map object has many properties which can be set in the object editor The editor is opened by double clicking on the object or from its context menu Click an item to set up its properties Data Data source
245. ulated when the report is run Link to a detailed page This link type works in the same way except that another page in the current report is used as a detailed report For this your report must contain at least two pages one with the main report another with detailed one You must set the following parameters for this type of hyperlink e page name in that report e name of the report s parameter which will take the hyperlink s value e hyperlink value Report creation 147 Edit Hyperlink URL Report page Page number a Pages Report parameter Bookmark CLategoryName wt Report Specify 4 parameter value Report page pT or enter the expression that returns a parameter value Custom Categories CategoryName je What will happen if you click this object in the preview window Specified page will be generated and opened in separate preview tab Modify the object s appearance so it will look like a clickable link When the link is clicked the following will take place e the report s parameter will be set to the hyperlink s value e the indicated report page will be built and shown in a separate preview window Report parameter s value can be indicated by using two methods e indicate the value directly e indicate an expression which returns the value This expression will be calculated when the report is run When you choose a report page its Visible property resets to fals
246. uyu Guarana Fant stica 20 Grandma s Boysenberry Spread Ipoh Coffee 17 Gula Malacca Lakkalik ri 57 Louisiana Fiery Hot Pepper Sauce Laughing Lumberjack Lager 5 Louisiana Hot Spiced Okra Outback Lager 15 Northwoods Cranberry Sauce Rh nbr u Klosterbier 125 Original Frankfurter gr ne Soe Sasquatch Ale 111 Sirop d rable Steeleye Stout 20 Vegie spread 559 Conditional totals In the previous example total was calculated for all data rows We can limit this range by Units In Stock 13 23 0 39 120 2r fas 4 6 Jz 115 24 507 indicating the condition in the total editor Total will be calculated for only those rows whose condition returns true For example we can set the following conditions Edit Total Total Total name TotalUnits Function Sum Data column or expression Products UnitsInStock Evaluate on each row of the band aa Data Products w Evaluate if the Following condition is met Products Discontinued Print on the band asa Footer Products we Options Reset after print Reset if band is repeated _ Include invisible rows 236 Data This will mean that total should be calculated for those products whose Discontinued flag is not set Running totals In our example totals were reset after printing the Data Footer band This occurred because we indicated in total editor that it is necessary to reset the total after printing it As a result each category print
247. valuate on each row of the band combobox choose the group footer in the Print on the band combobox place the Text object which prints the total value on the group footer For example for printing the number of rows in every group configure the total as follows Edit Total Total Total name Function Count Data column or expression Evaluate on each row of the band as Data Products Evaluate if the Following condition is met Prink on the band aasa Group Footer Category Name Reset after print Reset if band is repeated _ Include invisible rows Cancel In order to display the value of the total drag it onto the group footer 102 Report creation Group Header CategoryName Products Categories CategoryName Products ProductName faFouUp Fo aoter Prepared report will be like this Meat Poultry Slice Mutton Perth Pasties Th ringer Rostbratwurst Pate chinois Tourti re Mishi Kobe Miku Produce Rossle Sauerkraut Uncle Bob s Organic Dried Pears Manjimup Dried Apples Longlife Tofu Tofu Repeating the header and footer Group header and footer have the RepeatOnEveryPage property It can be useful if the group does not fit on one page of a prepared report By using this property you can print the group header footer on each page where the group is printed When printing such header footer FastReport sets its Repeated flag This can be used f
248. value FLOAT Converts the specified value to float Example ToSingle 1m 1f PO Lee ee TT ToString Function Parameters Return value TOCE TNO object value SEIS TEAC Converts the specified value to string Example ToString false False ToString DateTime Now 08 09 2009 4 45 00 PM Data 229 ToWords Function Parameters Return value ToWords object value SEAS Converts the specified currency value to words Example ToWords 1024 25 One thousand and twenty four dollars and 25 cents Function Parameters Return value ToWords object value SPANG string currencyName Converts the specified currency value to words The currency Name parameter indicates the currency Valid values for this parameter are USD EUR GBP Example ToWords 1024 25 EUR One thousand and twenty four euros and 25 cents Function Parameters Return value ToWords object value EEAO SECENG ane SE eh Tako Many Converts the specified integer value to words The one parameter contains the name in singular form the many parameter contains the name in plural form Example ToWords 124 page pages One hundred and twenty four pages ToWords l page pages One page ToWordsEnGb Function Parameters Return value ToWordsEnGb object value EE EAO Converts the specified currency value to words in Great Britain english There are the following differences between this function and ToWords
249. venue data column to the matrix cell Set the appearance of the matrix in the following way Employee Year Total Mame Revenue Total Now let us add three Shape objects to the cell with Revenue value These objects will serve as indicators in the following way e if value in a cell is less than 100 only one object of red color will be shown e if value in a cell is less than 3000 two objects of yellow color will be shown e if value in a cell is more or equal to 3000 three objects of green color will be shown Now the matrix looks like this Employee Year Total Name HEE Revenue Total To control objects we will use an event handler for a matrix cell For this select the Revenue cell and create the BeforePrint event handler using the Properties window Write the following code in the handler private void Cell4 BetorePrint abject sender EventArgs amp In our example a cell has the Cell4 name Get cell value which is in the Cell4 Value property Some cells in our matrix will be empty We ll take it into account null check The value should be cast to decimal type because data source column MatrixDemo Revenue is of System Decimal type decimal value Cell4 Value null 0 decimal Cell4 Value Switch shape objects on or off depending on the value value lt 100 one object is visible value lt 3000 two objects are visible value gt 3000 all
250. veral products How can related data sources be used in FastReport There are two methods of doing this Data 201 First method makes it possible to build reports of master detail type To do this two Data bands are used The master band is connected to the master data source the detail band to detail data source Our example will be like this ye fee ste PEE ata Ca LEQOreS 1 Categories Category Name Products ProductName iil Such a report if you run it will print a list of products in every category Beverages Chai Chang Chartreuse verte Coke de Blaye Guarana Fant stica Ipoh Coffee Lakkalik6ori Laughing Lumberjack Lager Outback Lager Rh nbra u Klosterbier Sasquatch ale Steeleye Stout Condiments Aniseed Syrup Chef Anton s Cajun Seasoning Chef Anton s Gumbo Mix genen Showy Grandma s Boysenberry Spread Gula Malacca The second method allows referring to the master from the detail data source We will show this by an example Let us say we want to print a list of all the products For this we need one Data band which is connected to the Products table Products ProductName L Such a report will print all the products from all the categories Let us say beside each product we want to print a category name to which it belongs Without using relation this would have been harder All we know about the product s category is its
251. wing way Datasource name Column name As you can see the square brackets are used here The data source name and data column name are separated by the period For example Employees FirstName Read more about using the data columns in the Expressions chapter There are several ways to insert a data column into the Text object 1 In the Text object s editor we write the name of the data column manually This method is the most inconvenient as it is easy to make a mistake 2 In the object s editor we choose the needed data column and drag amp drop it into the text Edit Text g Data Sources B E Employees 42 EmployeelL LastName A A TitkeorCourtesy BirthDate E HireDate Address City Region PostalCode Word wrap 3 Click on the small button in the upper right corner of the object and choose the data column from a list Fundamentals 31 Mone Category IO L LA CategoryMame Description Picture 4 Drag amp drop a data column from the Data window into the report page In this case the Text object is created which contains a link to the column HTML tags You may use some simple HTML tags in the Text object By default tags are disabled to enable it go Properties window and set the HtmlTags property to true Here is a list of Supported tags Tag Description lt b gt lt b gt Bold text lt i gt lt i gt Italic text lt u gt lt u gt Underlined text l
252. wizard you can select the tables which you want in your report When you have done press the Finish button Editing a data source Data source which was created with the help of the Data Wizard can be edited In order to do this choose the data source in the Data window and press the Edit button on the toolbar You will see a Query Wizard window which we have looked at earlier In this window you can change the SQL query text set up the query parameters and data columns In order to delete the data source select it and press the Delete button on the toolbar During this physical deletion of the source does not occur it just changes to inaccessible You can enter into the Data Choose Report Data menu and enable such a data source However this should never trouble you because deleted data sources are never saved in the report file and accordingly do not get restored when the report is being read the next time Data 199 Aliases Every data element data sources and columns has got its own name By default this is the name defined in the database In some cases it can be difficult to understand what is hidden behind such name for example ProdID Data elements have got a second name alias By using an alias you can rename an element For example if we have got a data source CATEGORY_TABLE with a column called PROD_ID you can give the following alias CATEGORY_TABLE gt Categories PROD_ID gt Produc
253. ws CheckBox CheckedListBoxControl Displays a ListBox in which a check box is displayed to the left of each item 268 Dialogue forms I zr pi Ss H ee L_ fal anunn ComboBoxControl DataGridViewControl DataSelectorControl DateT imePickerControl GroupBoxControl LabelControl ListBoxControl ListViewControl MaskedTextBoxControl MonthCalendarControl Numeric UpDownControl PanelControl PictureBoxControl RadioButtonControl RichT ext BoxControl TextBoxControl TreeViewControl Represents a Windows combo box control Displays data in a customizable grid Displays two lists and allows relocating an item from one list to the other Represents a Windows control that allows the user to select a date and a time and to display the date and time with a specified format Represents a Windows control that displays a frame around a group of controls with an optional caption Represents a standard Windows label Represents a Windows control to display a list of items Represents a Windows list view control which displays a collection of items that can be displayed using one of four different views Uses a mask to distinguish between proper and improper user input Represents a Windows control that enables the user to select a date using a visual monthly calendar display Represents a Windows spin box also known as an up down control that displays numeric values Used to
254. x appearance choose Orange style for the matrix choose Tahoma 8 font for all matrix cells select the word Total with bold type choose Glass type filling for the cells in upper row disable the autosize of the matrix and increase the size of rows and columns After that the matrix will have the following view There is lack of the following things in the matrix e there is no title for the Name data column e sums are not printed in currency format You can add a title for Name data column in the following way e the text Year Employee can be put into the left upper corner of the matrix e diagonal line and the second Text object can be placed there as shown below 130 Report creation e enable the matrix title To do this choose the Show Title item in the context menu of the Matrix object Any text can be included in the title In order to set the data formatting select the whole cell area as shown in the figure below and set format by selecting the Format item in the context menu F 200 00 9 300 00 10 800 00 tle UYS UU 9 999 00 Example 2 Multilevel headers The matrix will have one value in a row two values in a column and one data cell We will get the previous example as a base and add a new item into it e we will add the Month data column to the row header to the right of Year item After adding a new item improve the appearance of the matrix It is also nece
255. xpression You can indicate several not more than three sorting conditions This can be needed for example if you want to sort the list of customers by their cities and after that by customer s name For each condition you can choose the order of sorting ascending or descending Another method of sorting data use the SQL query as a data source The query will be executed on the data server and return a sorted rows 72 Report creation Filtering the data In order to filter a row which is printed in the Data band call its editor and switch to the Filter tab Edit DataBand Data source Filter expression Sort Filter As a filter expression you can indicate any correct expression More details about expressions can be found in the Expressions chapter In the example above the following filter is used Products Discontinued false This means that all the data rows whose Disconnected flag is equal to false will be chosen You can use complex filter condition Products Discontinued false amp amp Products UnitPrice lt 10 This means that all the data rows whose Disconnected flag is equal to false and whose price is less than 10 will be chosen This filtration method supposes that the data source contains all rows part of which will be filtered If the data source contains a large amount of rows this can seriously slow down the report In this case you can use SQL query as a data source i
256. xt menu just right click on the cell Joining and splitting cells You can join adjacent cells of the table As a result there will be one big cell In order to do this select the first cell with the help of a mouse left click and without leaving it move the mouse in order to select the group of cells on the selected region right click the mouse in order to show the context menu of the cells in the context menu choose the Join cells item In order to split a cell call its context menu and choose the Split cell item Inserting objects in cells In the cells you can insert other objects for example the picture The following objects can never be added into the cells e Table e Matrix e Subreport In order to add an object into the cell simply drag it inside the cell You can freely move an object between cells and also take it back beyond the table s boundary 110 Report creation LCHIPIUY EES CIP slid iit Name Froniavees Aastha Title Employees Title Phone Employees HomePhone in o Total Coun Cellz Photo Oo Oo Ct o ra A cell serves as a container to objects placed into it This means that you can use the Dock and Anchor properties of an object inside the cell This allows changing the size of the object when the size of the cell is changing Printing a table A table can be printed in two modes In the first mode the table is printed inside the band which it be
257. y in the preview window This property determines whether the object will be displayed in the report Invisible object is never displayed in the preview window and is never printed on the printer as well This property determines whether the object will be printed on the printer If this property is disabled then the object will be visible in the preview window but it will not be printed This property makes it possible to make the report object interactive Read more about this property in the Interactive reports chapter This property is used together with the Hyperlink property It can contain any expression The expression will be calculated when the report will be working and its value will be used as bookmark s name Fundamentals Restrictions This property restricts certain operations such as moving resizing deleting the object Style You can assign the style name to this property When this is done the object will become like it has been indicated in the Style If the parameters of the style changes the appearance of the object changes as well The Text object The Text object is the main object which you will use often It looks like this Text Text Text L l The object can display any text data specifically one or several text lines data columns report parameters total values expressions any combination of the above items Text editing In order to edit an object s text ju
258. y of the parameter The way it can be used in an expression depends on parameter s data type FastReport converts reference to a report parameter into the following way string Report GetParameterValue Parameterl1 Expressions 247 Script Script is a higher level programming language which is part of the report Script can be written in one of the following Net languages e C e VisualBasic Net A script is applicable in many places Using the script you can do the following control the formation of dynamic Table objects and many more perform data handling which cannot be done via regular means of the FastReport engine control the printing of report pages and bands on the page control the interaction between elements on dialogue forms In order to see the report s script switch to the Code tab in the designer The main class ij FactReport Semple List fre Fie Edt View Report Data Help A ee ape i 0 fof 9 oo le uzing Syecem using System Collections using System Collectiong Generic using System Component Hokiel using System Windows Forms uzing Systen braving using System bata using Fastheporet using FascRepore bata using FastRepoct Dialog using FastReport Barcoda using FastRepoct Table using FascRepore Ucils namespace FastRepoct public class ReporeSceipe private void Picturel Click object sender E code Pagel __ Pagez 75 4 25 on 4am
259. you click this object in the preview window Specified report will be opened in separate preview tab Modify the object s appearance so it will look like a clickable link As a report name choose the name of the detailed report file Report parameter can be chosen from the drop down list by pressing the button on the right side of the list As a parameter value indicate the Categories CategoryID expression Run the report and you will see the categories list Beverages Condiments Confections Dairy Products Grains Cereals Meat Poultry Produce Seafood If you click on one of the categories a detailed report will be built It will be shown ona 154 Report creation separate tab of the preview window Detailed report tab Close detailed report Eel d Print E 5a E 4 Sh 100 i Al E m N 4 1i ofi P Close interactive masterrepart g Product Name Quantity Per Unit UnitPrice Chocolade 10 pkgs 12 75 Gumbar Summiba rchen 100 250 g bags 31 23 Maxilaku 24 50 g pkgs 20 00 MuNuca Nu Mougat Creme 20 450 g glasses 14 00 Pavlova 32 500 g boxes 17 45 Schogagi Schokolade 100 100 g pieces 45 90 Scottish Longbreads 10 boxes x 8 pieces 12 50 Sir Rodney s Marmalade 30 gift boxes 51 00 Sir Rodney s Scones 24 pkgs x 4 pieces 10 00 Tarte au sucre 45 pies 49 30 Teatine Chocolate Biscuits 10 boxes x 12 pieces 9 20 valkoinen suklaa 12 100 g bars 16 25 faanse koeken 10 4 oz b
Download Pdf Manuals
Related Search
Related Contents
ヘッ ドレス ト取り付けキッ ト Manuel d`utilisation ALM42 - Alm4tî - S BaByliss X-10 DEUTSCH ENGLISH digitalSTROM GN Lifestyle Spas - Interline Products User's Manual - Libero 4.1 sicemotopi - gbycelectromecanica.com HP リテールモバイルPOSケース 300-486 manual.indd Copyright © All rights reserved.
Failed to retrieve file