Common FastReport. Net functions and fastreport.net Functions

Source: Internet
Author: User

Common FastReport. Net functions and fastreport.net Functions
I. common controls

 

Text Box: Enter text or expression

Table: set the number of rows and columns in the Table. Enter a number or expression.

Subreport: After you place a subreport, the system automatically adds a page on which you can design the required report. When the system prints the report, it first prints the report based on the Main Report. When a subreport is hit, it is automatically transferred to the subreport page for printing and processing. After that, it continues to print the report, therefore, it is also called a nested report.

Check box: whether to display √ (such as gender and female) based on whether the Boolean expression is true or not)

Barcode: bind a scan code (such as a static ticket). Generally, the Type is Code128.

Cross tabulation: Matrix

Page settings: Set the paper size and margins

Border settings: Set whether to display the upper, lower, and left borders and the setting of border lines

Border Width: You can select Border Width settings from the drop-down triangle.

 

Ii. Common Report Columns

Report title area (ReportTitle): only the first page is displayed on the top of the paper. It is generally used to print the title and other information of a report.

 

ReprotSummary: displays only at the end of all data. It is generally used to print statistics.

 

PageHeader: displays at the top of each page. You can set it to be placed above or below the report title. It is generally used to print the header information.

 

Data: bind a data source to display data.

 

Header: it is displayed at the top of all data sources and printed only once. It is generally used to display the summary information. The difference with the header is that when there is no data on the page, the content at the beginning of the data is not displayed and is only displayed once.

 

Footer: it is displayed at the bottom of all data sources and printed only once. It is generally used to display the total information of all data.

 

ColumnHeader: it is displayed on the top of the data source on each page. Therefore, it is generally used to print the topic information of the data source field.

 

ColumnHeader: it is displayed at the bottom of the data source on each page. Statistics can be used to display the total page information of each page.

 

Group header (GroupHeader): used to display group data.

 

GroupFooter: corresponds to the first group footer. It is generally used to display statistics of group data.

 

PageFooter: it is displayed at the bottom of each page. It is generally used to print page order and other information.

 

Iii. Common functions

 

1. Add a report bar

 

Place the cursor in the "Set Report blocking" pop-up "segment Editor", and then select add or delete segments.

 

Note the following when adding segments:

 

1) select the location of the added segment. If you want to add a child data area, select the parent data area to be added and click Add "data area ,:

2) If the added data area is at the same level as the original data area, select any segment (except the data area) and click Add "data area ,:

2. Add a data source

 

Select "data" in the menu bar and select "Select data source" in the drop-down box. The "Select Report data" dialog box is displayed, which lists the data sources that have been transferred. Select the required data source and click "OK, in this case, the selected data source is displayed in the "data" list on the right of the interface. Select the data source and right-click and select "View data" to display the data contained in the current data source:

 

3. Add System Variables

For some variables that may be taken from the current system, such as time, page number, and serial number, select the corresponding variable in the system variable,

4. Add Summary

For some reports, you need to add a total row at the end of the data. In this case, you need to manually add a total. The summary item editor is displayed, and then add the summary data source in the Summary Item editor.

In the summary name column, you can set your own name to a total name;

You can select a summarized data source in "Data columns or formulas;

You can select the data area that participates in the summary for each column in the calculation section;

You can filter out the rows that meet the following criteria. When you write the total, a certain type of sum is calculated. For example, the sum of the total number of employees and the total number of retires is calculated, in this case, the write restriction conditions are required for filtering when writing total. For example, [Table1.GRXZ] = "1 ";

5. Add filtering, sorting, and grouping

Double-click the data area and click "edit data segment" to select, sort, and filter data sources.

 

Iv. common attributes 1. Page settings

Used to display the total number of pages (TotalPages). For example, the footer displays 1st pages/20 pages in total. The system scans the report for the first time to calculate TotalPages, and then generates the report for the second time. If Double pass is not used, TotalPages returns 0. Therefore, the report attribute doublepass must be set to true;

Setting Method: Click the report tree, click the top icon of the report tree, click Properties, and set doublepass to true. You can also select report in the properties box to set relevant properties!

2. Print settings

The pattern is fixed on the paper (for example, the prescription paper and the billing invoice). You only need to fill in the data according to the original sample, the ruler must be of good size. In order to have a better effect, we usually draw out items that already exist on the page and do not need to be printed. However, we need to set the property "printable" to false: indicates that the print is not displayed. If you do not want to see those that do not need to be printed during the preview, you need to set the attribute "Visible" to false, indicating that the preview is not displayed.

3. format settings

Some data in the report needs to be displayed in the specified format. To change the time format, right-click the current data, and click format (or select format in the attribute column ), in the pop-up select format box, select the desired format. If there is no required format in the format, you need to customize it in custom. For example, if you need to set the time To 11:22:23, you can enter the time display format in custom: yyyy-MM-dd HH: mm: ss. Note that the message displayed in the morning or afternoon indicates that the format for the morning and afternoon is tt. For specific settings, see the existing format!

4. Display Settings

For some data, the name is long. When the row is high and fixed, the system uses a line feed by default. At this time, neither of the two cannot be completely displayed. For example, according to the customer's requirements, if Automatic truncation is required, set "WordWrap" to false (that is, do not automatically wrap the line). If you want to display all the data, you need to enable the automatic scaling function based on the cell size, set "AutoShrink" to fontsize or fontwith.

5. Border settings

You can set the border through the toolbar. In this case, the border is displayed based on the size of the external box, and the lower border can also be set with an underscore, at this time, the bottom border length is determined based on the length of the data display. You can also set the attribute "underline" to true, which is also displayed based on the border size.

6. Table settings

1) number of rows and columns in a table: Set ColumnCount (column) and RowCount (ROW) through attributes.

2) Merge/split cells: select the cells to be merged/split, right-click them, and select "merge cells"/"split cells ",

 

3) Insert rows and columns: Right-click a row or column and select the position to be inserted,

 

5. Common Code

 

1. Write in the text editor

 

The Fastreport software provides many functions to convert data directly in the editing box.

 

Common functions include:

Select statement IFF; control statement Switch;

Extract the string statement SubString and select SubString from the text list.

Truncation Time statement Date & Time:

Arithmetic statement Mathematical: commonly used Abs (take absolute value ).

 

Note: when using these functions, the usage rules of the current function are displayed in the lower right corner of the text editor,

 

If the current data type does not meet the rule, you must use the preceding conversion statement to convert it to a data type that matches the rule before using these functions. Otherwise, an error is reported.

 

2. Write in the code Area

 

Some data conversion cannot be directly implemented in the editor. You need to write code in the code area. Before writing code, define the corresponding event: select the report where the data to be written is located, click in attribute settings, and double-click the expected event in the event, automatically jump to the code area and a line of code appears, similar to private void groupheader+beforeprint (object sender, EventArgs e)

 

{

 

}

 

Common reports include BeforePrint and AfterPrint.

 

3. Common Code

 

1) Data1.InitDataSource (); // data initialization, used to run data twice

 

2) some users need to separate the year, month, and day. At this time, they need to select a time and only display a certain part of the time. For example, if a DateTime2 parameter value is 20120919, they need to separate the year, month, and day, displayed on _ years _ months _ days, respectively. You must use the function provided by fastreport for separation, that is, the method in 1. However, note that this method can only be used for data of datetime type; for non-datetime data, you can write code to retrieve the digits or perform forced conversion. Take string as an example:

 

Private void columnfooterinclubeforeprint (object sender, EventArgs e)

 

{

 

String tbrq = (String) Report. GetColumnValue ("Table1.TBRQ "));

 

If (! String. IsNullOrEmpty (tbrq ))

 

{

 

Text9.Text = tbrq. Substring () + "year" + tbrq. Substring () + "month" + tbrq. Substring () + "day ";

 

} // The string type uses SubString and Substring (0th) to indicate that the value starts from bits and the four bits are taken as the year.

 

3) decimal point control: You can use format to control the decimal places of all data, but it is only valid for numeric data. However, for string data, you need to use statements, such:

 

Decimal sl = (Decimal) Report. GetColumnValue ("dtbench. Quantity ");

 

Cell51.Text = sl. toString ("0.00"); // "0.00" if not specified, the default value is displayed. The number of digits that are followed by zero is the number of decimal places, sometimes a decimal point is required, and an integer is displayed if no decimal point is required. In this case, you only need to change "0.00" to "0. # ", # can be customized, indicating the maximum number of decimal places displayed.

 

Summary of special functions

 

1. In printing, empty tables can be filled with the remaining blank rows to reach the specified number of rows.

 

1. display the specified number of rows on a single page

 

To enable the page to display the specified number of rows N without filling up the data, you must add a subreport (child) in the data area ), the minimum data row (CompleteToNRows) must be set to N.

 

 

 

 

2. display the specified number of rows based on the number of data rows

 

According to the setting of 1, when previewing, you will find that this operation only controls the homepage to meet the conditions. When the number of data rows exceeds one page, the following page displays the number of rows based on the data, write code control.

 

For example:

 

Private void pageheader=afterprint (object sender, EventArgs e)

 

{If (Engine. FinalPass)

 

{

 

Child1.CompleteToNRows = (Int32) Report. GetVariableValue ("TotalPages") * 20;

 

} // Control CompleteToNRows based on the total number of pages * 20.

 

}

 

In this case, the child area CompleteToNRows in the report block is set to 1,

Ii. Total of this page and total of this period 1. Total of this page

The sum of the data on the current page is displayed on each page. Select "reset after printing" and move the total item to the corresponding position.

 

 

 

2. subtotal for current period

The total data is displayed on each page, but the total data is displayed on the last page of the data to calculate all the data and sum in the current report. You need to write total to calculate the current value, this attribute is reset only after the subtotal is printed in the current period. Because the subtotal is only displayed on the last page, the data area on other pages is empty and requires code control. For example:

Private void columnfooterinclubeforeprint (object sender, EventArgs e)

{

If (Int32) Report. GetVariableValue ("Page "))! = (Int32) Report. getVariableValue ("TotalPages") // set the conditions required to display the current subtotal. That is, when the current page is consistent with the total page number, the data is displayed. Otherwise, it is null.

Iii. cross tabulation usage (demonstration)

Refer to the template billing Summary Report. frx

Note that you do not need to set the row and column width of the crosstab chart. It is automatically set according to the Data Length.

Iv. Set up a template (DEMO)

Reference template outpatient registration invoice (SET). frx, prescription (Comprehensive). frx

Registration invoice Template

Note: In the zhoupu project, because the prescription document templates are different, different templates will be called at the doctor's workstation. In this case, several different templates will be combined, then, call the corresponding template according to the flag.

5. hyperlink template (DEMO) Report & document import 1. Document Import

The document is directly imported into the data source by developers. The document is drawn in the module.

Step: Find the corresponding module, click Print, enter the blank template, and then design. For templates that have been drawn, You can import them directly. However, you must clear the data source locally and import the template again. Otherwise, duplicate data partitions will occur, resulting in a different name, such as data11.

Even if some templates clear the data source and import it to the template, an error is returned. You need to create a new template and copy the original template.

Associated tables: select * from Common. ReportTemplate

Ii. Report Import

A report is implemented by a stored procedure and then corresponds to the stored procedure to store the data in the process.

Step: Report Management. Create a report. Enter the relevant information and save (DEMO). Draw a template.

Note: When entering the information, you must bind the correct stored procedure, and change the corresponding interface display effect through the foreground.

Add Data source: Select SQL, select the corresponding stored procedure, and click OK. For the newly created template, you do not need to select the template column. If you select this option, the previous template will be called, at the same time, the changes will also affect the previous template.

Associated tables include:

Select * from Common. Report

Select * from Common. ReportDataSource

Select * from Common. ReportTemplate

Select * from Common. ReportFolder

Select * from Common. ReportParameter

 

Note: fastreport has its own Demo, which provides many functions for your reference.

 

 

 

 

 

 

 

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.