Creating Reports and Labels in Specify 7
TIBCO Jaspersoft® Studio is the software used to create and modify reports and labels for Specify 7. It will help you design and run report templates; write complex expressions; layout visual components and much more.
If you would like to see a walkthrough of the user interface of Jaspersoft Studio, please see the Wiki available on the Jaspersoft Community website.
Step 1: To get started, download Jaspersoft® Studio from the Jaspersoft Community or from Sourceforge.
Please Note: Specify is compatible with Jaspersoft® Studio up to v6.21.3.
Later versions (Jaspersoft Studio v7+) do not currently work as it is incompatible with Specify 6 label and report formatting.
Step 2: In Specify, navigate to the Queries item in the navigation menu.
Click the icon to the right of the query you would like to make into a report or label.
Important!
If you update this query later, the changes will not be reflected in your generated report or label. To add additional fields, you will need to modify the query, export it again, and copy the specific<field>
information into the JRXML. You can follow this tutorial to update your existing reports or labels.
From here, you can select whether you would like to define a report or label based on the current query.
In this instance, we will be defining a label. The concept is fundamentally the same for a report.
Give the new label a name and click Create.
Now you will be brought to the app resources page containing your newly generated report or label:
Now you need to click Download. This will download a JRXML file you will open in Jaspersoft® Studio. Take note of where this is saved as it will be required in the next step.
Teaching Label.jrxml (2.2 KB) ← Here is the file above. It is a blank label, but you can take a look at the code in a XML editor app such as Notepad++ on Windows or BBEdit on macOS.
Step 3: Open Jaspersoft® Studio.
From the menu bar, click File → Open File.
Once you have selected your JRXML (in this case, Teaching Label.jrxml), you should see this blank screen. The name of your report or label should appear above the body of your blank label in a tab format.
Step 4: In the Outline section located in the bottom left quarter of the screen, expand the Fields item.
This contains the internal name for all of the fields in your query.
Important!
These fields are located below the top section of your JRXML file (starting at line 24). They can be manually edited, and this will be important if you ever wish to add fields to an existing report or label in Specify 7.
Query in Specify:
Lines 24-36 in Teaching Label.jrxml:
<field name="1.collectionobject.catalogNumber" class="java.lang.String"/> <field name="1,9-determinations.determination.determinations" class="java.lang.String"/> <field name="1,63-preparations.preparation.preparations" class="java.lang.String"/> <field name="1,9-determinations,4.taxon.Family" class="java.lang.String"/> <field name="1,93.collectionobjectattribute.text13" class="java.lang.String"/> <field name="1,93.collectionobjectattribute.text14" class="java.lang.String"/> <field name="1,63-preparations.preparation.remarks" class="java.lang.String"/>
You can see that Jaspersoft® Studio uses the field name from the file Specify output rather than the user-friendly name assigned to the field in the Schema Config tool. You will need to know the name of the field at a database level rather than the custom name assigned in the aforementioned tool. Fortunately, the order of the query is preserved in the JRXML file, making it easy to find the correct field based on its position in the query.
You can modify the dimensions of the report or label by right-clicking on the name of the report or label and clicking Show Properties.
Report Name is the name that will appear associated with the current report. Ensure that you name the report appropriately according to its function for optimal use.
Imports are Java classes that can be used to execute special events during printing. Users that are familiar with Java can include custom scriptlets in this tab.
You can use the Edit Page Format option to pick the exact dimensions you would like to establish.
Page Size designates the area assigned to the report. Choose a predefined size or create a custom size.
Page Margin delineates the non-printing margins around the page.
Columns can be used to create multiple labels per page or columns of data.
You can alternatively use the Advanced section to modify all properties manually. Here you can modify the height, width, margins, print order, column count, and more.
Step 5: Keep only the necessary bands for your report or label.
Once the report or label is generated, an empty report template will appear. Jaspersoft Studio separates reports into sections, or bands. Data is then printed according to the band definition. For example, a title is printed once, but detail is repeated for every record. Bands can be resized by holding the mouse on the separator line until cross hairs appear, then clicking and dragging the line. Bands can also be removed if not needed by dragging the lower edge of the band onto the upper edge (thereby making its height zero).
Report Band | Description |
---|---|
Title | Only created once in the report and can be its own page. |
Page Header | Appears on all pages (except title and summary pages that are included as their own page) in the same position. |
Column Header | Printed at the beginning of each detail column. |
Detail | Corresponds to every record that feeds the report. |
Column Footer | Appears at the end of every column. |
Page Footer | Appears on every page that includes a page header. |
Last Page Footer | Creates a unique footer for the last page. |
Summary | Allows fields to be inserted for ending statements such as total calculations or means. |
Because I am building a label, I only need to retain the Detail band. For reports, they are often much more complex and require the other bands.
Reports Example:
The KU Fish Loan Shipping Form (available from our Jaspersoft reports gallery) retains the Title, Page Header, Column Header, and Detail 1. Reports often require these sections to display correctly. You can download this example and more from our page linked above.
Step 6: Drag the fields you wish to use in the label or report onto the body.
Important!
After dragging & dropping a field on the report body, you will see two items appear.
The item on the left is static text and should be removed. It will not change or update when the report is run. You can change the value of this field to act as the label for the field.
The item on the right is an expression. This will update with the proper value when the report or label is run. This should be kept.
An expression is a formula that operates on some values and returns a result, like a formula in a spreadsheet cell. A cell can have a simple value or a complex formula that refers to other values. In a spreadsheet you refer to values contained in other cells; in Jaspersoft Studio you use the report fields, parameters, and variables. Whatever is in your expression, when it’s computed, it returns a value (which can be null if nothing is returned).
For more information on how to use expressions to accomplish a range of display outputs in Jaspersoft Studio and Specify iReport, please refer to Getting Started with Reports.
Combining Fields, or creating a concatenated string, is often useful in a report.
- Add the first field in the concatenated string to the proper band (by dragging and dropping) and keep it active (a colored box will appear around the field).
- Double click on the field.
- The Expression Editor will appear. The original field will be included in the top window as an expression. There are 3 boxes under the window, make sure the first box has Fields selected and find the next field in the second box and double click to add it to the top window.
- Each combination of fields requires a linking argument in the following format: + "x " + where x is the text string required to link the two fields. ‘x’ can also be omitted if no linking text is require i.e. + “” +
For example:
$F{1,10.collectingevent.startDate}+$F{1,10.collectingevent.startDate}
Note: Typing (+ " " +) between two field expression in this dialog will include whatever text is between quotation marks to appear on the report.
Step 7: After placing every field you wish to include, add styling, formatting, and other components to the label.
In the top right quadrant of the application, you will see a list of elements that can be added to the body. Specify supports the Text Field, Static Text, Image, Break, Rectangle, Ellipse, Line, and Barcode elements. The composite elements can be added as well.
Specify supports the following barcodes:
2of7 Code128B EAN13 SCC14Shipping APCA 3of9 Code128C Global Trade Shipment Identifier UPC3 Bookland Code39 Int2of5 SSCC18 UPC4 Codabar Code39(extended) Monarch Std2of5 USPS Code128 EAN128 PDF417 UCC128 Text can be added to the report by clicking the button in the elements box, then clicking and dragging a box in the desired band. These are handy for creating captions, titles, headers and footers. Lines, shapes, images and barcodes can also be added using buttons on the tool bar. Simply mouse-over a button for a tool tip displaying its function. These elements are added as static text fields.
Once in a band, fields can be moved by dragging with the mouse or using the Ctrl and arrow keys while fields can be resized by pulling any of the edge or corner handles of an object. Objects can also be manipulated by using the Top, Left, Height and Width commands in the common section of the Properties pane (see below).
Images can be added to the report the same way. Clicking on the button in the elements box then clicking and dragging a box in the desired band will allow you to determine its size and dimensions.
Note: Images must reference a URL or linkage that is accessible by the Specify 7 installation. You cannot point to a local image on your machine or else Specify will throw an error when the report is run. The best practice is to have it point to a public URL containing the image you are linking to.
In this example, I have added the following fields to the label as well as an image that links to an external URL.
Important!
You can configure a field to be blank if there is no value. This is extraordinarily useful for fields that often do not contain a value. If you want it to appear blank if the entire field value is null, you can check Blank When NULL.
If you want to have a segment of an expression to not appear if it is null, you can modify the field expression to show
For example, you can structure the expression for your field like this:
($F{field}==null?"":$F{field})
. Here is an example of this with the Continent field from another query:($F{1,10,2,3.geography.Continent}==null?"":$F{1,10,2,3.geography.Continent})'
This says if the field
1,10,2,3.geography.Continent
is empty, display “” (or no value), but if it is not, display1,10,2,3.geography.Continent
.It is not uncommon to use this to string together many fields into one expression while hiding the null values. This expression displays the Continent, Country, State, Locality Name, and Latitude1 and Latitude2 with the degree symbol after each coordinate. Importantly, only fields that display results from the base query will appear!
(**$F{1,10,2,3.geography.Continent}** ==**null**?"":**$F{1,10,2,3.geography.Continent}** )+(**$F{1,10,2,3.geography.Country}** ==**null**?"":", " + **$F{1,10,2,3.geography.Country}** )+(**$F{1,10,2,3.geography.State}** ==**null**?"":", "+**$F{1,10,2,3.geography.State}** )+(**$F{1,10,2,3.geography.County}** ==**null**?"":", "+**$F{1,10,2,3.geography.County}** )+(**$F{1,10,2.locality.localityName}** ==**null**?"":", "+**$F{1,10,2.locality.localityName}** )+(**$F{1,10,2.locality.latitude1}** ==**null**?"":", "+**$F{1,10,2.locality.latitude1}** +"°").toString()+(**$F**{1,10,2.locality.longitude1}==**null**?"":", "+**$F**{1,10,2.locality.longitude1}+"°").toString()
Step 8: Click the Preview tab below the body preview. If everything loads correctly, the report is ready for Specify!
Step 9: Navigate to the Source tab below the body preview and copy the entire body of the newly created report or label.
Clear the current body of text in Specify then paste the entire contents of the Source into Specify 7’s app resource page for your newly created label or report. Now click Save.
Step 10: Run your new report or label from the Reports dialog.
Click Reports.
Click Teaching Label (the name of your new report or label).
See the results!
From here, you can tweak your label or report until you are satisfied.
Teaching Label Finished.jrxml (5.3 KB) ← Here is the finished product demonstrated here today! It is a very simple example of what you can accomplish with this software.
Teaching Label Output.pdf (337.4 KB) ← This is a PDF from Specify 7 after running the query (176 results).
If you have any questions, please refer to our Specify Report and Label Manual.
It is written for SpiReport and Specify 6, but the same principles and expressions work here. If you intend to use any Scriptlets mentioned in this documentation, please review the list of unsupported scriptlets in Specify 7.