Automatic blank line and line filling for Crystal Reports (no Group Edition)

Source: Internet
Author: User

Question:

For a list report with grid lines, suppose there are 6 rows, and the page pattern we set can accommodate 5 rows, the data will be divided into two pages.
5 rows are displayed on page 1, and 1 page is full. Only 1 row is displayed on page 2, followed by a blank area.
How can we automatically fill up the blank area based on the amount of data?

For example (page 1 ):

Solution:

For a list Report, the remaining area of the last page is to be filled. Let's take 5 rows of data per page as an example.
There are only five cases for the last page.
1: The last page has exactly five data records and does not need to be filled.
2: There are four in the last page, and one empty row needs to be filled; three empty rows need to be filled; two empty rows need to be filled; and one empty row needs to be filled, four empty rows need to be filled.

In this example, a maximum of four blank rows are added. Therefore, with the original data rows added, there should be five sections in the detail section.
The designed template is as follows:

Split the detail section into five sections. Put the data at the top and set it to display. All the other four sections suppress the display. We use a formula to control whether to display the details.

Line Drawing Method: Draw a box in the header and footer, and the bottom edge of the box is close to the top edge of the header.

Then draw a horizontal line at the top and bottom of each detailed section.

Draw a vertical line between fields. Note that the vertex under the vertical line must be placed on the line of the footer section.

Next we will control the display,

The following formula uses the crystal syntax

1: edit "detail section B" (that is, the first blank section, I put a field on it for marking, which is not required in actual use) to suppress the formula behind the display

Count ({employee. Date of birth}) mod 5Number of remaining entries on the last page. The values are 0, 1, 2, 3, and 4.

0 indicates it is full. If it is greater than 0, it indicates it needs to be filled.

 


// Note the two and conditions
// 1: Count ({employee. Date of birth}) mod 5> 0 indicates that the number of records is not a multiple of 5, that is, empty rows must be supplemented.
// For this section, as long as it needs to be supplemented, it is displayed
// 2: The onlastrecord condition is "whether it is the last record", indicating that this section appears only after the last record
// That is, it will appear on the last page.
If Count ({employee. Date of birth}) mod 5 > 0 And onlastrecord then False   // If the suppression display is selected, false means that the suppression is not performed. This section is displayed under this condition.
Else
True

 

So good, as longCount ({employee. Date of birth}) mod 5> 0,This blank section is displayed.

2: Set "details section C" and 2nd blank sections. Because the first detailed information section B has been shown before.

In this section, only two or more blank rows are needed, that is,Count ({employee. Date of birth}) mod 5 value must be 1, 2, 3
Then the formula becomes.

If Count ({employee. Date of birth}) mod 5 > 0 And count ({employee. Date of birth}) mod 5   <= 3 And onlastrecord then
False
Else
True

 

Continue. The "detail section D" and the 3rd blank sections will only appear inCount ({employee. Date of birth}) mod 5 must be 1 or 2

Therefore, the formula is



IfCount ({employee. Date of birth}) mod5>0And count ({employee. Date of birth}) mod5 <=2And onlastrecord then
False
Else
True

Continue. The "details section E" and the 4th blank sections will only appear inCount ({employee. Date of birth}) When mod 5 is 1

Therefore, the formula is



IfCount ({employee. Date of birth}) mod5 = 1And onlastrecord then
False
Else
True

Complete the settings.

If it is a number other than 5, it is assumed n.

Then the detailed information section is split into N, the first data is put, and the following formula is followed by so on.
The 1st blank rows are:
If count ({employee. Date of birth}) mod n> 0 and onlastrecord then

The formula for the first to last 2nd blank sections is as follows:
If count ({employee. Date of birth}) mod n> 0 and count ({employee. Date of birth}) mod n <= (N-2) onlastrecord then

If count ({employee. Date of birth}) mod n> 0 and count ({employee. Date of birth}) mod n <= (N-3) onlastrecord then
...
If count ({employee. Date of birth}) mod n> 0 and count ({employee. Date of birth}) mod n <= 2 onlastrecord then

The last empty row formula is:
IfCount ({employee. Date of birth}) mod5 = 1And onlastrecord then
...

In this way, you can set it.

Others:

How can we ensure that the Row Height of each row is the same?
First, do the first line, and then split the remaining lines in the expert section. The new row is shorter than the first row. Copy a field in the Data row. Paste it to the following rows. The Row Height is automatically adjusted to the height of this field.

Download the sample report with data (cr xi R2 standalone version)

 

 

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.