The implementation result is as follows:
The report page function is added to the simple application (ASP. NET) (CrystalReports) mentioned earlier.
When the data record is not one page long, it can be supplemented by blank rows.
First, analyze the report structure
It is easy to see that the report is mainly divided into the header, details, and footer. This document is fixed to the width and height of the paper. The details of our header are very good.
Yes, but in which section is the footer? (Question 1)
Each six rows of Data specifies one page. If there are only three rows of data in one page, how to keep the format of the printed documents from the footer unchanged?
Are three rows supplemented by blank rows? (Question 2)
Through analysis, we can think of using groups to achieve the desired effect.
1. the header is written to the header section, the details are written to the details section, and the footer is written to the end of the group;
2. Other blank rows are controlled by groups;
(1) determine the group ending number based on the number of lines on the page. There are at least five blank lines displayed on each page;
(2) divide the end Of the group into six parts. The first five items are used to control whether to fill blank rows, and the last line is used to display the footer;
Note: The above format settings are determined by the developers and do not have to be placed in these places. Currently, to achieve this effect, my implementation is as follows:
Implementation
1. Insert group: [field resource manager] → [insert Group]
(1) A group is easy to understand. If you put together data with one or more conditions, You must select a field as the basis for grouping. The data source
Here we use a. net object, which is a specific entity class. In this entity object, there is such an attribute dedicated to the identification of the group service, such:
// Private int crorder; public int Crorder {get {return crorder;} set {crorder = value ;}}
(2) the data source bound to the report is a List which may contain many records. To display 6 records on each page, you can simply set the value of the identification device to 6 records + 1
In this case, the default value is 0, and the number of records is changed to 1, and the number of records is changed to 2. In this case, the data is automatically separated by 6 records on each page according to this value, for example:
// In the method for getting the data source List, the total number of I records is processed in this way. 6 is the number of records displayed on each page, the temporary corder identifier, and m. Crorder is the group identification tool of the object.
if (i % 6== 0) { corder++; m.Crorder = corder; } else{ m.Crorder = corder; }
// If there are more than 6 0 records, it indicates that I is a multiple of 6 and you want to group the logs. If the remainder is not 0, it indicates that there are no 6 records on this page, group ID unchanged
The Group of Experts is as follows:
2. Insert the group at the end of the group, which is divided into six groups (a, B, c, d, e, f:
On the report panel, right-click Report> expert section to configure the report.
Note: If the configuration is mentioned, if it is not mentioned, use the default
Group Header
Click the button next to the new page to open and write: groupnumber mod 1 = 0 click Save and close as follows:
Group end
Click the button next to "suppress display" to write:
Note: ImportStoragePrintModel. number is an attribute of an object. Here, Count (field name) is used to Count the Number of rows, the function implemented by a at the end of this group is that if the number of rows in the last row except 6 is displayed when the remainder is between 0 and 5, otherwise, the display is not displayed. In the suppression display, false indicates that the display is not restrained.
If Count ({ImportStoragePrintModel. Number}) mod 6> 0 and Count ({ImportStoragePrintModel. Number}) mod 6 <= 5 and onlastrecord then
False
Else
True
Click Save and close as follows:
Below, only the B, c, d, and E code at the end of the group is pasted, and the image is shown as a at the end of the group.
Group end B
If Count ({ImportStoragePrintModel. Number}) mod 6> 0 and Count ({ImportStoragePrintModel. Number}) mod 6 <= 4 and onlastrecord then
False
Else
True
Group end C
If count ({importstorageprintmodel. Number}) mod 6> 0 and count ({importstorageprintmodel. Number}) mod 6 <= 3 and onlastrecord then
False
Else
True
Group end d
If count ({importstorageprintmodel. Number}) mod 6> 0 and count ({importstorageprintmodel. Number}) mod 6 <= 2 and onlastrecord then
False
Else
True
Group end e
If count ({importstorageprintmodel. Number}) mod 6> 0 and count ({importstorageprintmodel. Number}) mod 6 <= 1 and onlastrecord then
False
Else
True
The data source is bound to a simple application (ASP. NET) in crystalreports.