Fastreport.net Common methods

Source: Internet
Author: User
I've talked about the use of this report Tool Fastreport.net, but at that time mainly from the point of view of the program, examples in the B/s framework of the relevant use, but the report is still to be zoned into the design of the category, after all, can be the content of the report displayed in front of the customer, this is the basic purpose of the statement, And such as printing, conversion format personally think it should be a function of icing on the cake.

And with the complexity of the report design, the problem naturally increased, there is no way, the hard to get the officer net point document.

Here will encounter some of the small problems summarized as follows, make a record of their own, the need for friends can also save a bit of "reading comprehension" Time ha ...

 

One, Page Setup

Story: The Fastreport designer page defaults to A4 paper, but if you need to display too many fields, then there is a problem where the size of the page does not meet the full display of the content you want.

Resolve: After this problem, we can go to the "file"-"Page Setup" option to set, where you can directly adjust the paper type and size of the page, but I use more will adjust portrait for landscape, the so-called portrait by the word pa translation is " Paper short side at the top and bottom of the printing method, and landscape is the opposite, meaning "paper long side of the top and bottom of the printing way", can be simply understood portrait as portrait, landscape for the landscape, through such adjustments can be guaranteed with standard A4 paper printing, Also satisfies the design time can enlarge the paper size, guarantees the display content the goal.

  

  

Second, filter or sort the display data

Scenario: For the data to be displayed sequentially, it is easy to view.

Resolution: You can double-click the data area at this time, you will see the sorting and filtering options, you can click on the back of the FX icon, using the way to implement the designer, of course, you can also manually add code:

  

Third, add and set up subreports

Stories: Data that shows a complex relationship.

Resolve: Go to report--Set up the report bar--to make various settings for the report, where the data is printed only once, and the end of the data is printed after all the data.

  

  

Four, date display

Scenario: Some data table's date fields are empty, and fastreport automatically converts them to the 0001/1/1 form.

Workaround: At this point, if you want to leave the date blank without displaying this default form, you can go back to report--options, and uncheck ' Convert null ' on the General tab.

  

V. Nesting of data tables

Scenario: Complex database tables have a number of complex master-slave relationships, which need to be established in the data source.

Resolve: Select the action--new relationship, and then you can create a primary foreign key association as you would in the database.

  

VI. Manual determination of data sources

Scenario: Sometimes the relationship between SQL statements and tables is so complex that it's difficult to build good master-slave relationships, such as SQL queries I've encountered

SELECT I.sheetkeyid,i.sheetid,i.operatorname,
I.incheckdatetime,i.outcheckdatetime,i.outcheckpeople,
S1. Branchname as INBRANCHNAME,S2. Branchname as Outbranchname
FROM dbo. T_storagebranch S1, dbo. T_storagebranch S2,
Dbo. T_leechdomiosheet I, dbo. T_leechdomiosheet I2
WHERE I.inbranchkeyid = S1. Branchkeyid
and I2. Outbranchkeyid = s2. Branchkeyid
and I.sheetid = I2. sheetID

Since the relationship between the table and other tables, the establishment of master-slave relations will not be depressed death ...

Solution: There are two ways I can solve this problem. One is based on Fastreport is to support tables and views as a data source, you can set up a view in the database in advance to use the view as a data source to resolve the table's associated problems, of course, if there is no project requirements, can use the second method, that is, click " Add SQL query, this is the input of our SQL statement, we will automatically generate a query results, we only need to use it as a data source in the design of the report OK.

  

Vii. Use of System variables

Scenario: We often ask for the current number of pages, current data statistics, and current print times when the report is printed.

Solution: Fastreport In fact, we have built all of these functions, can be found in the system variables, simply drag into the date to display the current day, drag into the Pagen can display page numbers, and so on.

  

Eight, make the report display when the common odd and even line color effect.

Scenario: You can easily view data when you have a large amount of data.

Solve: There are also two ways, one is in the "Report"-"style" to add a style, called evenrows, what style is not set, OK, and then click the data area, in the appearance of the Evenstyle attribute select this style, and finally change the fill color of the filled property. The second method is implemented in the form of a program, with the following code:

private void Data1_beforeprint (object sender, EventArgs e)

{

if (((Int32) report.getvariablevalue ("row#")% 2 = 0)

Data1.fillcolor = Color.gainsboro;

}

Here the row# for the system built-in variables, representing the line number, we select even rows, set the FillColor for their own desired color, but not window color, so that can not see the effect.

Use the procedure to operate the report

Stories: In a form program, you can use programmatic methods to manipulate the related fields of a report.

Solve:

Get the value of a column in a data source

String productName = (string) report.getcolumnvalue ("Products.name");

    

Get Data source

Datasourcebase ds = Report.getdatasource ("Products");

Get system Variable Value

DateTime date = (datetime) report.getvariablevalue ("date");

Get Total count

Float sales = Report.gettotalvalue ("TotalSales");

Get parameters

int myparam = (int) report.getparametervalue ("Myparameter");

Setting parameters

Report1. Setparametervalue ("EmployeeID", 2);

Ten, notes

1, in the Fastreport variables are used in the form of [Datasourcename.fieldname], all in this form is required to read from the database, and ordinary text needs [text content] In this form can be done.

2, in the Fastreport can set the alias of the data table, so that in the case of multiple table association using aliases and related fields corresponding.

3, if you do not have the heart, I paste a few off-the-shelf based on the Northwind database demo example to see ...

  

  

  

  

It is estimated that so much, easy to use things to share with wow ... ^_^

Author: Rocky Xiang
Source: http://www.cnblogs.com/RockyMyx/
This article copyright to the author and blog Park Altogether, welcome reprint, but please in the article page obvious position gives the original connection, otherwise reserves the right to pursue legal responsibility.

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.