Jasper Report style isBold="true" not working in a conditionalStyle - jasper-reports

I'm using the Jasper Report library for Java v6.19.1 and the Report Design plugin for Eclipse.
I created this conditional style and I applied it to a text field.
<style name="myStyleBold">
<conditionalStyle>
<conditionExpression><![CDATA[$F{misura} == null]]></conditionExpression>
<style isBold="true" isItalic="true" isUnderline="true" isStrikeThrough="true"/>
</conditionalStyle>
</style>
All formats are working (isItalic="true" isUnderline="true" isStrikeThrough="true"), but the isBold="true" is never applied.
Anyone has the same issue or solved it?

Solved. The value must be < EREDITATO >. It was "false".

Related

JasperStudio How to use conditional style?

I am desperately trying to format the Field "FilmID" based on it's value. Could you provide me with a conditional expression to format values >= 3 in red color ?
Conditional Style
Thanks a lot in advance!
Another variant of this question would be, what did I do wrong in this expression:
<style name="Style1" mode="Opaque" backcolor="#DBD82A">
<conditionalStyle>
<conditionExpression><![CDATA[$F{Revenue} > 10000]]></conditionExpression>
<style mode="Opaque" backcolor="#C92B28"/>
</conditionalStyle>
</style>
Assuming that $F{Revenue} is numeric (Integer, Double, Float ecc)
if you are using jasper report version 6.0 or above there is nothing wrong with your style expression, for jasper report 3.0, you need new Boolean($F{Revenue} > 10000)in expression.
You need also to be sure that you apply the style to a report element.
<reportElement style="style1" x="49" y="4" width="100" height="20" uuid="865e11e4-c2d4-40ac-be06-dc1359dc93c0"/>

Removing trailing 0 xml Ireport

I'm currently having trouble when producing an iReport, when I run the report it's giving me a weight of 29000.0kg but I require just 29000kg. I've tried different formats but I understand it might need changing in XML.
If anyone could point me in the right direction or assist me in changing this please comments
Currently this is the XML code that is against fields:
<textFieldExpression><![CDATA[$F{EquipmentTareWeightKg} +"kg"]]></textFieldExpression>
Any ideas on how to include this?
I've figured this out, it doesn't require hardcoding but merely changed in the properties window within ireport designer, however if you see below, you change the pattern value to remove decimal places:
</textElement>
<textFieldExpression><![CDATA[$F{EquipmentLengthMm} /1000]]></textFieldExpression>
</textField>
<textField pattern="###0" isBlankWhenNull="true">
<reportElement x="399" y="0" width="32" height="20"/>
<textElement>
<font size="12"/>
</textElement>

How to apply jrtx style for static text in jrxml file

I have an issue on staticText tag into jrxml template.
I'm using iReport 5.0.4 and JasperReports to apply a jrtx style to my default jrxml template.
As soon i apply the style, every element labeled as staticText disappears.
As soon i remove the style, everythig show correctly. This seems strange, because other tags such as textField works properly,and i can change background color, font etc.
Maybe i do need to apply some tag properties, but i can't figure what is missing. The style is referenced with the tag. Please help on this
I found mistake and its working now and shared below code
<jasperTemplate>
<style name="rptlnbl" isDefault="true" hAlign="Center" vAlign="Middle"
fontSize="24" fontName="Arial" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false">
</style>
</jasperTemplate>
earlier i am updated isDefualt is false.After setting true and able seen jrtx file changes in jrxml.

Dynamic styling of row headers in JasperReports Crosstab

I am attempting to generate a cross tab report using JasperReports. The column contains time periods and the row contains different group by conditions. Now I need to change the styling of the row headers based on the level. For example, in the grid shown below, web and email need to be in bold while the other row headers are as is.
Now, I have a field in the bean that lets me decide if I should make the text bold or not, so I tried to use this in a conditional style as below
<style name="rowStyle" hAlign="Center">
<conditionalStyle>
<conditionExpression><![CDATA[$V{level}.intValue() != 0]]></conditionExpression>
<style isBold="true" hAlign="Left"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$V{level}.intValue() == 0]]></conditionExpression>
<style isBold="false" hAlign="Right"/>
</conditionalStyle>
</style>
and I have a field and a measure expression corresponding to this
<field name="level" class="java.lang.Integer"/>
<measure name="level" class="java.lang.Integer">
<measureExpression><![CDATA[$F{level}]]></measureExpression>
</measure>
However this style does nothing when used inside the crosstabRowHeader, it takes effect only inside crosstabCell.
So my questions are
Is anyway for me to use a conditional style inside the crosstabRowHeader?
More specifically, can I access any bean property within the crosstabRowHeader?
Managed to figure this out after all.
So the issue is to be able to access a property from the bean within the crosstabrowheader (or any other cross tab headers).
To do this first create a field corresponding to the bean as so -
<field name="voBean" class="com.jasper.reports.voBean">
<fieldDescription>_THIS</fieldDescription>
</field>
Then in the headers, specify this bean as the bucket class.
<rowGroup name="voBean" width="200">
<bucket class="com.jasper.reports.voBean">
<bucketExpression><![CDATA[$F{voBean}]]></bucketExpression>
</bucket>
You can now start to access any property on the bean as below
<textFieldExpression><![CDATA[$V{voBean}.getRowName()]]></textFieldExpression>
Hope this helps anybody else with the same problem.

External Styles in JasperReports

I'm working on a system that includes a large number of reports, generated using JasperReports. One of the newer features is that you can define styles for reports.
From the available docs I believe there is some way to have an external file defining styles to use, and you can reference that in your jasper reports. This allows a single style to be used by multiple reports.
I can't find any concrete information on whether this is an actual feature, and if it is, how to use it. Does anyone know if it is possible to have external styles for jasper reports, and if so, how to do it?
Use JasperReport templates. A JasperReports template is one that ends in .jrtx, and may look similar to this (styles.jrtx):
<?xml version="1.0"?>
<!DOCTYPE jasperTemplate
PUBLIC "-//JasperReports//DTD Template//EN"
"http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">
<jasperTemplate>
<style name="Report Title" isDefault="false" hAlign="Center" fontSize="24" isBold="true"/>
<style name="Heading 1" isDefault="false" fontSize="18" isBold="true"/>
<style name="Heading 2" isDefault="false" fontSize="14" isBold="true"/>
</jasperTemplate>
and then in your .jrxml file, include it as a template:
...
<template><![CDATA["styles.jrtx"]]></template>
...
iReport also understands this, so your styles are imported and shown in iReport correctly (though I did notice sometimes it wouldn't pick them up an a reload or recompile was necessary).
You can also avoid specifying the actual file name in the <template> element by using a parameter passed into your report at runtime
<parameter name="TEMPLATE_FILE" isForPrompting="false" class="java.lang.String"/>
<template><![CDATA[$P{TEMPLATE_FILE}]]></template>
where $P{TEMPLATE_FILE} is the full path to the style resource
I like to share my learning of using styles in Jasper reports, which I think quite useful for report designers like me, from a book named JasperReport Development cookbook by Bilal Siddiqui. I like this book and found demonstrating styles in a variety of manner like:
Creating a reusable style
Simply select “Style” while creating a new report and define style for text, line and rectangles. The style file will be stored as .jrtx file.
Import reusable style it in your report
There are three chunk of information when importing styles in your report.
Step1. Name and location of style template
<template><![CDATA["C:\\ BigBoldRedTemplate.jrtx"]]></template>
Step2. Each time you apply style to your report elements using the style template, a <reportElement> tag is created as shown below:
//style applied to a rectangle
<rectangle radius="10">
<reportElement style="BigBoldRed" mode="Transparent" x="0" y="0" width="555" height="44"/>
</rectangle>
//style applied to a the text field
<staticText>
<reportElement style="BigBoldRed" x="0" y="0" width="555" height="66"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Monthly Customer Invoices]]></text>
</staticText>
Mixing the internal and reusable styles in report
Using the power of HTML to style your report
For example, your text field has following expression which includes HTML tags (i.e. <li>) and you want the HTML tags to work in your report design:
"<li>"+"Invoice # "+$F{InvoiceID}+", "+
$F{CustomerName}+" purchased
"+$F{ProductName}+" in
"+$F{InvoicePeriod}+" (Invoice value:
\$ "+$F{InvoiceValue}+")"+"
Solution is simple, just set “Markup” property of the text field to “Styled” and that it.
I have taken permission from the author to copy code chunk from his JasperReports cookbook in this post.