Jaspersoft Tips
Jaspersoft Tips
Jaspersoft Tips
I.E.
• Implementacion de aulas funcionales.
• Sesiones de Aprendizaje en el Sitio
Oficial de la JEC.
• Implementacion de Plataforma
Educativa Moodle.
• Conexion a otras plataformas
Educativas.
Tips and Tricks – Jaspersoft Development
This document purpose is to give tips and tricks for a jaspersoft developer
Contents
How to Compare jrxmls ................................................................................................................................ 2
How to manually add Fields .......................................................................................................................... 2
Changing the Report Language ..................................................................................................................... 2
Repository Connection Information ............................................................................................................. 3
How to use Markup in a Field ....................................................................................................................... 3
How to Modify an OOTB Report ................................................................................................................... 3
Copy the Report ........................................................................................................................................ 3
Modify the Report..................................................................................................................................... 5
How to modify the colors on a chart ............................................................................................................ 6
How to add a Jaspersoft report into an iFrame ............................................................................................ 7
Increment Date Value ................................................................................................................................... 8
Conditional Styles – Override Issue .............................................................................................................. 8
How to find the number of times a String is in a string ................................................................................ 8
How to set default on a parameters ............................................................................................................. 8
Where is the user id stored in Jaspersoft come from via Clarity .................................................................. 8
Getting the previous value for a variable ..................................................................................................... 9
JasperServer.Api.Metadat.user.domain.User Class ...................................................................................... 9
Adding an Extension Font for PDF Export ................................................................................................... 11
How to set a default date to start of (Year, Month, Day) ........................................................................... 11
How To Set Excel Export To Create New Sheets Per Group ....................................................................... 11
Query Functions with Regex expressions Loading in the DWH .................................................................. 12
Passing Parameters down to sub reports using a HashMap ...................................................................... 12
Scheduled Jobs not Deleted after Report Deleted ................................................................................. 12
LISTAGG Issue Workaround .................................................................................................................... 12
Removing the ability for the user to change graph style ........................................................................ 12
Ex: http://community.jaspersoft.com/questions/534014/use-style-text-expression
a.
3. Once this is applied you can apply the selected markup in your textfield expression.
a. Example: I want my field “name” to be bold. I am using the markup “Styled”.
"<style isBold='true'>" + $F{NAME} + "</style>" + " - " +
($F{SR_UPDATE} != null ? $F{SR_UPDATE} : "No Update")
8. This will copy the entire Report Unit into this folder. This will allow us to edit the report via
Studio without modifying the original report.
Modify the Report
1. Open Jaspersoft Studio.
2. Open the local workspace and create a Jaspersoft project to store the jrxml that will be updated.
3. Navigate to the Repository in which the new copied report is stored.
4. Find the JRXML report file to be edited. Open the properties for this file by right clicking on the
file and selecting properties
5. Once in the properties of the jrxml, download the file to the workspace created in step 2.
10. Now the report has been edited and can be ran on the environment without issue.
How to modify the colors on a chart
Edit Chart Properties -> Chart Data tab -> Configuration tab -> Click on Category Level -> Click Modify
button -> Go to Bucket Properties tab. Click Add. Name the property color and give it an expression to
define the color of the slice. Here’s an example:
<script>
vars = str.split("&");
if (pair[0] == "id") {
key = pair[1];
</script>
Second, we can now add the following line inside the “script” tags, after the above code, to update
the iFrame source location. In this example, we’re linking to a quick project list report, passing the
parameter projectKey_1 and updating the iFrame with id “projectList”:
document.getElementById('projectList').src = 'https://cppm1080-
dev.ondemand.ca.com/reportservice/flow.html?_flowId=viewReportFlow&standAlone=true&decorate=
no&ParentFolderUri=/users/regoconsulting/reports&reportUnit=/users/regoconsulting/reports/Project
List&projectKey_1=' + key;
Note: Not hard coding the iframe size results in poor sizing for the report
Increment Date Value
The function EDate lets you add and subtract months. You would need to figure out how to subtract
days by a %. Example below.
EDATE(NOW(),6)
You can remove the styles from the GUI but an easier route is removing from the source. Example
below.
Removing the “attributes” of the report element will allow the style to work.
In the default value expression on a parameter set the value that would be passed via the input control.
Boolean: TRUE
Integer: 5006063
JasperServer.Api.Metadat.user.domain.User Class
public interface com.jaspersoft.jasperserver.api.metadata.user.domain.User extends
com.jaspersoft.jasperserver.api.common.domain.AttributedObject,com.jaspersoft.jasperserver.api.met
adata.user.domain.TenantQualified {
}
Adding an Extension Font for PDF Export
Adding a PDF Font Style to be exported can help when a font is not available out of the box in the PDF
Exporter. The following steps show how to add one.
1. Download the TTF for the font that you need to use. Make sure to get both the BD (Bold),
regular, and italicized versions available. Note: Some fonts do not have italics, research will be
needed.
2. Add the TTFs to the jaspersoft server.
a. Create custom font folder
b. Right Click on folder and click add File -> Font
c. Add the TTF and click submit
d. Navigate to the properties and copy the path.
3. Once the path has been copied, embed it in the following syntax pdfFontName=“path”
a. Ex: pdfFontName="repo:/Custom_Reports/Custom_Fonts/tahomabd.ttf"
4. Navigate to jaspersoft studio and in the style or on the text field directly add the tag you saved
in step 3.
Ex. <style name="Section_Header" mode="Opaque"
backcolor="rgba(228, 126, 2, 0.2509804)" fontName="Tahoma"
fontSize="12" isBold="true"
pdfFontName="repo:/Custom_Reports/Custom_Fonts/tahomabd.ttf"/>
Note: If you need the end month dates to be relative, make sure to do a
DAYSINMONTH expression.
Also add the xls.sheet.name and use an expression to name it based on the group.
<reportElement style="Section_Header" x="0" y="0" width="2100" height="30"
uuid="1805e2ec-3348-48bb-ba88-758166a1c8bb">
<property
name="net.sf.jasperreports.export.xls.break.before.row" value="true"/>
<propertyExpression
name="net.sf.jasperreports.export.xls.sheet.name"><![CDATA[$F{FUNCTIONAL_LEAD
_GROUP}!= null ? $F{FUNCTIONAL_LEAD_GROUP} : "No Functional
Lead"]]></propertyExpression>
</reportElement>
Query Functions with Regex expressions Loading in the DWH
With the Query lookups, if you have REGEXP functions, it may give a DWH Load error. You will need to
replace that with older style functions.
Also if you have SUBSTR, you may get an error on the DWH load. If you do, then change it to
@SUBSTR@.
Similarly with NVL, if you have it in lookup where clause change it to @NVL@.
Way easier than writing each one out, especially when your creating a report book that can have 5+
parts
http://community.jaspersoft.com/documentation/tibco-jasperreports-server-administrator-
guide/v60/scheduler-running-deleted-jobs
com.jaspersoft.jasperreports.highcharts.interactive = “false”
How to Hyperlink from your report
To hyperlink to your report you need to define a textfield or object to put the hyperlink on. This can be
an image, text field, etc.
1. Go into Jaspersoft Studio and find your resource on the report you want the user to select to
link to another report or website.
2. Navigate to the properties of the resource
6.
7. If linking to an external URL, like another report, use the Link Target as Self. Link Type ahs
ReportExecution.
8.
9. In the parameters, make sure to define the parameter _report and the URI the report is located
in the repository. Ex: "/Custom_Reports/Top_20_Dashboard"
a. Note: You can also add additional parameters to pass to the report such as INVKEY, just
like you would a sub report.
b. Note: We have seen bugs with collection parameters, so test thoroughly.