Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasper Reports new line

I'm new in Jasper Reports. I use iReport 4.5 in NetBeans. I need create some text and insert into text new variable. All works, but new line doesn't create. Tell me please, how to solve it? Thanks!

`<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="jasper_report_template" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50">
    <property name="ireport.zoom" value="1.3310000000000004"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="ReportTitle" class="java.lang.String"/>
    <parameter name="Author" class="java.lang.String"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="country" class="java.lang.String">
        <fieldDescription><![CDATA[country]]></fieldDescription>
    </field>
    <field name="name" class="java.lang.String">
        <fieldDescription><![CDATA[name]]></fieldDescription>
    </field>
    <title>
        <band height="240" splitType="Stretch">
            <textField isBlankWhenNull="true" bookmarkLevel="1">
                <reportElement x="0" y="0" width="515" height="27"/>
                <textElement textAlignment="Center">
                    <font size="10" pdfEncoding="Cp1251"/>
                </textElement>
                <textFieldExpression>
                <![CDATA["Some text "+ $P{ReportTitle} +" my name +"<br/>"+ is "]]>
                </textFieldExpression>
                <anchorNameExpression><![CDATA["Title"]]></anchorNameExpression>
            </textField>
        </band>
    </title>
    <columnHeader>
        <band height="24" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="21" splitType="Stretch"/>
    </detail>
</jasperReport>`
like image 369
Alex85 Avatar asked Dec 20 '22 15:12

Alex85


1 Answers

OlliZi answer is not valid if a parameter contains a <br>, and Kamel's answer is not valid if you don't use the same iReport version... So this is the universal answer in the .jrxml file.

Add markup="html" to the used style or in the reportElement, without using a specific editor. Very usefull for fast and compatible fix.

<textField>
    <reportElement x="0" y="0" width="100" height="50" markup="html" />
    <textFieldExpression>
        <![CDATA["Some text "+ $P{ReportTitle} +" my name +"<br/>"+ is "]]>
    </textFieldExpression>
</textField>

Or, if you use a style:

<style name="myStyle" markup="html" />

<textField>
    <reportElement x="0" y="0" width="100" height="50" style="myStyle" />
    <textFieldExpression>
        <![CDATA["Some text "+ $P{ReportTitle} +" my name +"<br/>"+ is "]]>
    </textFieldExpression>
</textField>
like image 64
Al Foиce ѫ Avatar answered Mar 19 '23 19:03

Al Foиce ѫ