Skip to main content Skip to footer

Introduction to Fixed Page Layout–Part 3

Welcome to the last post in this short series on Fixed Page Layout in ActiveReports Developer 7. There is more to come in the future about ActiveReports Developer 7 though.

Overflow is an important concept in FPL reports, and a powerful feature is the ability to decide where to put it. Overflow occurs whenever the content in a data region grows beyond what can fit in the area allotted by the data region's FixedSize property. Once the content overflows, the reporting engine looks to see what it should do with the rest of it. It takes direction from the OverflowName property on each data region.

If the property isn't set then it just uses the same page over again to display the additional data. If it is set, then it begins filling the designated OverflowPlaceHolder on the report with additional data. Once the OverflowPlaceHolder is filled, it repeats the process, looking for the appropriate placeholder to fill. Using the OverflowName property and the OverflowPlaceHolder control you can create sophisticated layouts easily.

Overflow Example

To demonstrate, we'll create a simple report which uses overflow to fill up two columns on one page, and an additional page that uses a slightly different layout. This report will contain inventory data and a place for someone to write down the actual count. We'll start by creating the report and gathering the data.

Create a new Page report, and in the Report Explorer, right click the Data Sources node and select Add. Check the "Shared Reference" box and browse to the Reels.rdsx. This adds DataSource1 to your Report Explorer. Right click on DataSource1 and choose Add Data Set. Go to the Query page and use the following query: SELECT * FROM DVDStock

Our data is somewhat wide, so we'll set the left and right margins to 0.5in.

Adding the controls

Drop a table onto the report and drag the Title and InStock fields into the first two columns. In the last column we'll put a series of underscores that will be the line for the stock people to write on. Resize the columns as needed to show the data. I found 2.5in, 0.625in, and 0.5in worked well. Place the table against the left margin and position it high on the page. Set the FixedSize Height property so that it fills the page.

If we preview the report right now, you'll see that we get this same page repeated over and over again with our additional data displayed. One thing that is missing is the table header on each subsequent page. To add it, select the table header and set the RepeatOnNewPage property to True.

Now according to our design, we wanted a second column for the data; this is easy to add. Drag an OverflowPlaceHolder to the right side of the report and align it with the table. On the table, set the OverflowName property to OverflowPlaceHolder1. Once you do this, the placeholder resizes itself. Reposition it on the page if you need to. That is all we need to do to create the second column!

Lets add a header to this report and then we're done with this page. Drag out a textbox and set the text to Inventory Report and make it fairly large for the title. You can also add a Page N of M to the top. If you preview the report now, you'll find both columns filled; but we are still using this same page over and over again. We already know that this is the inventory report, so we don't need to repeat it on each page. Let’s design a new page without this header.

Creating the second page

At the bottom of the designer is the page bar. Right click on Page 1 and choose Duplicate. Duplicate takes the page you are duplicating and copies its contents, replaces any data regions with OverflowPlaceHolder controls, and then hooks those placeholders up in the chain. The result is that all we need to do is remove the header info we don't want, and make both overflow placeholders taller. Now we can preview the report and get a unique first page design with all subsequent pages having the second design.

Themes and Collation

In ActiveReports Developer 7 we've revamped our theme support from Data Dynamics Reports, changing the way colors are used, and we added a new feature, the ability to add constant strings to the theme.

What is the use of a constant string in the theme file? Well, we also added the ability to have multiple themes in a single report that you can use one after the other to produce replicated forms that differ only in styling or static text. You may have seen this before where a delivery driver has nearly identical slips: one for you, one for him, and one for the office. So with the new collating feature you can print out these delivery slips or other multi-copy documents from a single report!

We'll create a basic report which uses this feature to create the delivery slips we mentioned earlier.

Example

Create a new Page report, and set the page margins to 0in and the page size to 4.5in x 3.5in. In the Report Explorer, right click the Data Sources node and choose Add Data Source. Under the Type dropdown, specify the "Xml Provider" and in the Connection String box type: XmlDoc=path to file\orders.xml

Click OK to accept our data source and close the dialog. Right click on our newly added data source and choose "Add Data Set." Data sets in an XML data source use XPath. to pull the data out of the file. Set the query string to the XPath query which will return the elements you wish to work from (one element per "row" of data) and then the fields are constructed via additional XPath expressions to pull the individual items from the elements returned.

Set the query string to: //orders/order/items/item

Go to the Fields page and add the following fields:

Field Name

Value

OrderID

../../@id

Name

../../address/name

Address

../../address/street

City

../../address/city

State

../../address/state

ZIP

../../address/zip

Item

@item

Count

number(@count)

Click OK to accept our list of fields and close the dialog.

Now that our data is set up we can begin constructing our report. Drag out the Name, Address, City, State, and ZIP to form a nice address header near the top of the report. Now add a table and put the Item and Count fields in it, sizing the table appropriately. If you right click on the rightmost column header you can remove it so it is just the two columns.

Set the table's FixedSize property so that it takes up most of the page, but leave room for a textbox at the bottom. This textbox will tell the driver which of the three copies they are looking at; we'll add that in a bit. Finally, we need to set up fixed page grouping.

Click the white background of the report and at the bottom of the property grid click the “Property dialog” command. On the Grouping page, click in the "Group On" list and select the OrderID field.

If you preview the report now you will see three pages in the report, one for each of the customers and their orders.

Now for the fun part! We're going to create a theme to set the background color of the report (since we're not really printing it) and in the theme we'll also specify which copy of the report this is for.

On the Report menu, select Report Properties. Go to the Themes page, and click the New button on the toolbar. This launches the theme editor. We'll use Accent 1 as our background color so click on that color box and choose White. Since all we're interested in is this one color and the text, go ahead and go to the Constants tab.

In the Name column, type "Copy" and in the Value column, type "Customer." When we are using this theme, the Copy value will contain Customer. Click OK to exit the theme editor and save the theme.

Now we'll do the same thing again, only this time choose a faded yellow color for Accent 1 and specify "Driver" as the value for "Copy" on the Constants tab. Click OK to exit the theme editor and save the theme.

Finally, once more but choose a faded pink color for Accent 1 and specify "Office" as the value on the constants tab. Once again, click OK and save the theme.

Now that we have our themes, its time to apply the values.

Click on the white background of the report (if your report has margins you need to click in the middle of the report and not on the margins of the page) and specify your background color, in this case click the 3rd icon in the drop down to switch to the themes page, select Accent1 here or you can type in the expression: =Theme.Colors!Accent1

Next add a textbox to the bottom of the report in that space we saved before. Set its value to: =Theme.Constants!Copy

If we preview the report now we'll have three copies of the slips. However, if you run through the pages you'll see that you get all of the Customer copies first, followed by Driver copies, and finally the Office copies. What if you want each order to print its Customer, Driver, and Office copies together? Fortunately this is easy to do with the Collate option. In the Report Explorer, click on the Report node at the very top, in the property grid you'll find the Collate property. If you change this to "Value" you'll now get each order's slips printed together!

Well, that's it. We've covered a lot of things in FPL but there is much more available in ActiveReports Developer 7. Check back soon for the next post in the "What's New in ActiveReports Developer 7" blog series, or subscribe to our RSS feed to stay up to date. Next time, we'll look at what's new in the Windows Forms Viewer control.

MESCIUS inc.

comments powered by Disqus