brownfordson Posted September 28, 2022 Share Posted September 28, 2022 Apologies, I am new to Jasper studio. I have a textfield that comprises text imported from a resource file. In the text field, a substring within one of the strings is replaced with a variable (a field $F{}) imported from a database. I need this variable to appear in bold in the exported file. I have tried creating a new variable using the <style isBold='true'></style> tags with markup of the textfield set to styled.I have also tried integrating this directly into the text field. I am not getting an error. I am not getting unconverted tags. I am simply seeing no result whatsoever. Does anyone know what might be going wrong? Is it even possible to do this? Several responses on StackOverflow have said they suspect this is not possible in JasperStudio and I just want to be sure before I throw this back to the client. Thank you. Link to comment Share on other sites More sharing options...
luked Posted September 28, 2022 Share Posted September 28, 2022 Have you tried creating a new style? Click on the style field in the report outline and create a new style, then once you have created that, right click on that new style and create and conditional style. In there you can put in an expression to make the field bold. then in your report text field in the properties window you can select the style you created. Link to comment Share on other sites More sharing options...
jgust Posted September 28, 2022 Share Posted September 28, 2022 >> I need this variable to appear in bold in the exported file. Based on this requirement, you have to set the textbox Markup property. Markup can be styled, HTML, rft, or NONE. HTML is probably your best bet. Conditional style is a good approach but might be overkill for your needs. That said you can follow this link for how-to screenshots https://community.jaspersoft.com/questions/1199566/how-do-i-bold-cell-table-based-value Here is a sample report with both conditional style and markup text:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.14.0.final using JasperReports Library version 6.14.0-2ab0d8625be255bf609c78e1181801213e51db8f --><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="Blank_A4_Landscape" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="14147cb5-a441-4dbf-9397-a90041afb815"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="PeimsDS"/> <property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w1" value="331"/> <property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w2" value="664"/> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> <conditionalStyle> <conditionExpression><![CDATA[$F{FIRSTNAME}.equals( "Bob" )]]></conditionExpression> <style isBold="true"/> </conditionalStyle> </style> <subDataset name="Dataset1" uuid="3c8b22a6-915e-4ee7-b6e8-e579c7269adc"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="PeimsDS"/> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <queryString> <![CDATA[sELECT schoolname, lastName, firstName, Address, Countryfrom ( select 'El Dorado HS' as schoolname, 'Smith' as lastname, 'Jane' as firstname, '123 Main St' as Address, 'Canada' as country from dual union all select 'El Dorado HS','Smith','Bob','321 Main St','Spain' from dual)]]> </queryString> <field name="SCHOOLNAME" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="SCHOOLNAME"/> <property name="com.jaspersoft.studio.field.label" value="SCHOOLNAME"/> </field> <field name="LASTNAME" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="LASTNAME"/> <property name="com.jaspersoft.studio.field.label" value="LASTNAME"/> </field> <field name="FIRSTNAME" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="FIRSTNAME"/> <property name="com.jaspersoft.studio.field.label" value="FIRSTNAME"/> </field> <field name="ADDRESS" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="ADDRESS"/> <property name="com.jaspersoft.studio.field.label" value="ADDRESS"/> </field> <field name="COUNTRY" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="COUNTRY"/> <property name="com.jaspersoft.studio.field.label" value="COUNTRY"/> </field> </subDataset> <queryString> <![CDATA[sELECT schoolname, lastName, firstName, Address, Countryfrom ( select 'El Dorado HS' as schoolname, 'Smith' as lastname, 'Jane' as firstname, '123 Main St' as Address, 'Canada' as country from dual union all select 'El Dorado HS','Smith','Bob','321 Main St','Spain' from dual)]]> </queryString> <field name="SCHOOLNAME" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="SCHOOLNAME"/> <property name="com.jaspersoft.studio.field.label" value="SCHOOLNAME"/> </field> <field name="LASTNAME" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="LASTNAME"/> <property name="com.jaspersoft.studio.field.label" value="LASTNAME"/> </field> <field name="FIRSTNAME" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="FIRSTNAME"/> <property name="com.jaspersoft.studio.field.label" value="FIRSTNAME"/> </field> <field name="ADDRESS" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="ADDRESS"/> <property name="com.jaspersoft.studio.field.label" value="ADDRESS"/> </field> <field name="COUNTRY" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="COUNTRY"/> <property name="com.jaspersoft.studio.field.label" value="COUNTRY"/> </field> <background> <band splitType="Stretch"/> </background> <columnHeader> <band height="22" splitType="Stretch"> <staticText> <reportElement x="11" y="0" width="100" height="16" uuid="7408d444-3aac-4e47-ac60-62c0b78dc671"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="86cce99b-447a-4214-8124-fa26731175e6"/> </reportElement> <box> <bottomPen lineWidth="1.0"/> </box> <text><![CDATA[sCHOOLNAME]]></text> </staticText> <staticText> <reportElement x="126" y="0" width="100" height="16" uuid="7b5ce5b9-5274-43b2-89cd-7cb6ba739a0d"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b932a47-b9e1-4889-9dde-535afe55587f"/> </reportElement> <box> <bottomPen lineWidth="1.0"/> </box> <text><![CDATA[LASTNAME]]></text> </staticText> <staticText> <reportElement x="241" y="0" width="100" height="16" uuid="f6016038-8138-4229-a1bc-53446d6f6ddc"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="e6550816-63e6-4953-a5b0-447de08c127d"/> </reportElement> <box> <bottomPen lineWidth="1.0"/> </box> <text><![CDATA[FIRSTNAME]]></text> </staticText> <staticText> <reportElement x="351" y="0" width="100" height="16" uuid="b78a9d07-a664-4cd2-ad87-829266b37810"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6d926e78-a369-4a6a-b67b-c770cf20e691"/> </reportElement> <box> <bottomPen lineWidth="1.0"/> </box> <text><![CDATA[ADDRESS]]></text> </staticText> <staticText> <reportElement x="467" y="0" width="100" height="16" uuid="04737ffa-ad85-4cc8-a786-f5daf1db9755"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a855fdd6-b977-4173-83a8-af303e6d3dbf"/> </reportElement> <box> <bottomPen lineWidth="1.0"/> </box> <text><![CDATA[COUNTRY]]></text> </staticText> <staticText> <reportElement x="600" y="2" width="189" height="16" uuid="2ab7cacd-012c-4160-8f18-f4d373889dbb"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a855fdd6-b977-4173-83a8-af303e6d3dbf"/> </reportElement> <box> <bottomPen lineWidth="1.0"/> </box> <text><![CDATA[bold First, Last (HTML Markup)]]></text> </staticText> </band> </columnHeader> <detail> <band height="19" splitType="Stretch"> <textField> <reportElement x="11" y="5" width="100" height="14" uuid="ca4e0843-b327-4442-a262-cc18d0fd772a"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="86cce99b-447a-4214-8124-fa26731175e6"/> </reportElement> <textFieldExpression><![CDATA[$F{SCHOOLNAME}]]></textFieldExpression> </textField> <textField> <reportElement x="126" y="5" width="100" height="14" uuid="643a7d95-58d8-4a0b-a7d3-355c0766e820"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b932a47-b9e1-4889-9dde-535afe55587f"/> </reportElement> <textFieldExpression><![CDATA[$F{LASTNAME}]]></textFieldExpression> </textField> <textField> <reportElement style="Table_TD" x="241" y="5" width="100" height="14" uuid="05a882e2-8e40-43bc-aa8c-b3f2da01d7ee"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="e6550816-63e6-4953-a5b0-447de08c127d"/> </reportElement> <textFieldExpression><![CDATA[$F{FIRSTNAME}]]></textFieldExpression> </textField> <textField> <reportElement x="351" y="5" width="100" height="14" uuid="f905aa8c-2baa-4ee8-aa4f-fd0ed2bdfe8a"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6d926e78-a369-4a6a-b67b-c770cf20e691"/> </reportElement> <textFieldExpression><![CDATA[$F{ADDRESS}]]></textFieldExpression> </textField> <textField> <reportElement x="467" y="5" width="100" height="14" uuid="4d931cc1-73cf-4402-a3be-62d4f91110e6"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a855fdd6-b977-4173-83a8-af303e6d3dbf"/> </reportElement> <textFieldExpression><![CDATA[$F{COUNTRY}]]></textFieldExpression> </textField> <textField> <reportElement x="600" y="2" width="189" height="16" uuid="3a7acd60-54fa-4951-b23c-f6bcb845b637"/> <textElement markup="html"/> <textFieldExpression><![CDATA["<b>" + $F{LASTNAME} + "</b>," + $F{FIRSTNAME}]]></textFieldExpression> </textField> </band> </detail> <summary> <band height="50"> <componentElement> <reportElement x="19" y="16" width="684" height="31" uuid="8300bf26-d8d7-43b5-9043-ee3efe8b4cb5"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/> <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/> <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/> </reportElement> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="Dataset1" uuid="96e376b3-295a-4727-88ca-12531566b1e5"> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:column width="163" uuid="7432c5d7-5669-416a-b631-9ad82a37bf75"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="163" height="20" uuid="355fb50d-27fb-4aaa-8942-27db4173ea61"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="86cce99b-447a-4214-8124-fa26731175e6"/> </reportElement> <text><![CDATA[sCHOOLNAME]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="163" height="30" uuid="93a04327-81c1-4f50-912c-fbe7c292767f"/> <textFieldExpression><![CDATA[$F{SCHOOLNAME}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="160" uuid="f198c408-e346-4d86-b412-76ca0a420584"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="160" height="20" uuid="fd9e324e-6bc5-459c-ac57-5c9d1a865d4b"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6b932a47-b9e1-4889-9dde-535afe55587f"/> </reportElement> <text><![CDATA[LASTNAME]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="160" height="30" uuid="ce9003e5-93d4-410e-99fa-772b46126c61"/> <textFieldExpression><![CDATA[$F{LASTNAME}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="106" uuid="1a7e311c-d8e1-403a-a987-f1f8956b9dfe"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="106" height="20" uuid="636eb699-2fd9-4b71-9d39-613bace04181"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="e6550816-63e6-4953-a5b0-447de08c127d"/> </reportElement> <text><![CDATA[FIRSTNAME]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement style="Table_TD" x="0" y="0" width="106" height="30" uuid="ab9c0eec-9885-4329-ab49-3d9354ee03dc"/> <textFieldExpression><![CDATA[$F{FIRSTNAME}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="123" uuid="6ae57f18-13de-45c9-b621-39669ec707ae"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="123" height="20" uuid="1b65d902-656d-40a2-bac4-073d4592098b"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6d926e78-a369-4a6a-b67b-c770cf20e691"/> </reportElement> <text><![CDATA[ADDRESS]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="123" height="30" uuid="da80131d-f4d9-413d-b458-9c447f61147d"/> <textFieldExpression><![CDATA[$F{ADDRESS}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="132" uuid="6ad8095f-9a5c-4c65-be8d-0f3766872f1a"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="132" height="20" uuid="343a1c0f-e5c1-4de9-999f-cbe92ef061a4"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="a855fdd6-b977-4173-83a8-af303e6d3dbf"/> </reportElement> <text><![CDATA[COUNTRY]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="132" height="30" uuid="294e9ae7-ffaa-4e5a-ab61-d9dd7476eac7"/> <textFieldExpression><![CDATA[$F{COUNTRY}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </summary></jasperReport>[/code] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now