Quantcast
Channel: Pochampalli IT Labs
Viewing all articles
Browse latest Browse all 261

Tip : Part of text "red" in color with "underscore" for Text field expression in Jaspersoft reports Or Styled Markup example in Jasper Studio

$
0
0
Problem Statement : 
Get part of text "red" in color with "underscore" for text field expression

Solution : 
Use "styled" Markup on text field with expression written with "style" tag. 

Text field expression: 
"Hi, This is regurlar text"+"<styleforecolor=\"red\"isUnderline=\"true\">Styled Markup for red color text with underscore in Text Field Expression</style>"+"  This is normal text "+"\n"+"no later than the following date: "+"<styleforecolor=\"red\">This text is in red color without underscore</style>"


Sample jrxml design (Tap onto the image for better visibility)

Sample report output(Tap onto the image for better visibility)
JRXML(works from 7.2 studio professional)
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 7.2.0.final using JasperReports Library version 6.6.0 -->
<jasperReportxmlns="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="Styled Markup for red color text with underscore in Text Field Expression"pageWidth="620"pageHeight="470"whenNoDataType="AllSectionsNoDetail"columnWidth="620"leftMargin="0"rightMargin="0"topMargin="0"bottomMargin="0"uuid="f5ee6cd9-fdbd-4655-a337-ef2568c81a56">
<propertyname="com.jaspersoft.studio.data.sql.tables"value=""/>
<propertyname="com.jaspersoft.studio.data.defaultdataadapter"value="Sample DB"/>
<propertyname="ireport.jasperserver.url"value="https://dev-lockton-cms.seventablets.com/jasperserver-pro/"/>
<propertyname="ireport.jasperserver.user"value="superuser"/>
<propertyname="ireport.jasperserver.report.resource"value="/organizations/organization_1/Lockton_Reports_1/Test/Styled_Markup_for_red_color_text_with_underscore_in_Text_Field_Expression_files/main_jrxml"/>
<propertyname="ireport.jasperserver.reportUnit"value="/organizations/organization_1/Lockton_Reports_1/Test/Styled_Markup_for_red_color_text_with_underscore_in_Text_Field_Expression"/>
<propertyname="com.jaspersoft.studio.report.unit.description"value="001_RP_Stop Loss Marketing Analysis"/>
<propertyname="com.jaspersoft.studio.unit."value="pixel"/>
<propertyname="com.jaspersoft.studio.unit.pageHeight"value="pixel"/>
<propertyname="com.jaspersoft.studio.unit.pageWidth"value="pixel"/>
<propertyname="com.jaspersoft.studio.unit.topMargin"value="pixel"/>
<propertyname="com.jaspersoft.studio.unit.bottomMargin"value="pixel"/>
<propertyname="com.jaspersoft.studio.unit.leftMargin"value="pixel"/>
<propertyname="com.jaspersoft.studio.unit.rightMargin"value="pixel"/>
<propertyname="com.jaspersoft.studio.unit.columnWidth"value="pixel"/>
<propertyname="com.jaspersoft.studio.unit.columnSpacing"value="pixel"/>
<queryStringlanguage="SQL">
<![CDATA[]]>
</queryString>
<summary>
<bandheight="460"splitType="Stretch">
<propertyname="com.jaspersoft.studio.unit.height"value="px"/>
<textField>
<reportElementx="50"y="25"width="530"height="40"uuid="c43bf219-e07c-4286-afcd-c8136a487828"/>
<textElementverticalAlignment="Bottom">
<fontfontName="Garamond"size="16"isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Styled Markup for red color text with underscore in Text Field Expression"]]></textFieldExpression>
</textField>
<textField>
<reportElementmode="Opaque"x="30"y="100"width="35"height="35"forecolor="#FFFFFF"backcolor="#000000"uuid="3edcc7ee-d3fa-4bc7-a02e-d7744e776592">
<propertyname="com.jaspersoft.studio.unit.height"value="px"/>
</reportElement>
<textElementtextAlignment="Center"verticalAlignment="Middle">
<fontfontName="Garamond"size="16"isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["1"]]></textFieldExpression>
</textField>
<textField>
<reportElementx="65"y="100"width="485"height="35"uuid="3261f9a0-a9c6-460e-9943-87c9c3cd2dad">
<propertyname="com.jaspersoft.studio.unit.height"value="px"/>
</reportElement>
<boxleftPadding="10"/>
<textElementtextAlignment="Left"verticalAlignment="Middle"markup="styled"/>
<textFieldExpression><![CDATA["Hi, This is regurlar text"+"<style forecolor=\"red\" isUnderline=\"true\">Styled Markup for red color text with underscore in Text Field Expression</style>"+" This is normal text "+"\n"+"no later than the following date: "+"<style forecolor=\"red\">This text is in red color without underscore</style>"]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>


Viewing all articles
Browse latest Browse all 261

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>