Jasper Report не поддерживает все теги html, теги поддержки определены в Образец стилизованного текста
Как видите, теги <s>
и <strong>
не поддерживаются.
Ваш выбор - заменить их на <font style="text-decoration: line-through">
и <b>
, если вы хотите использовать html
или
<style isStrikeThrough="true">
и <style isBold="true">
, а затем использовать стилизованный текствместо html.
Если у вас есть динамические данные, вы можете использовать java для их замены
${myField}.replace("<s>","<font style=\"text-decoration: line-through\">").
replace("</s>","</font>").
replace("<strong>","<b>").replace("</strong>","</b>")
Если вам нужно заменить несколько тегов, я бы порекомендовал создать метод в java(статический) и вызовите этот метод вместо выполнения замены в отчете
Пример
jrxml
<?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="html" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fe5b2242-b491-46ba-8456-aa71ae5e2212">
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="53" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="210" height="50" uuid="e462bb03-e884-4b5b-b41f-2867a4bd63b2"/>
<textElement markup="html"/>
<textFieldExpression><![CDATA["<s><s></s> and <strong><strong></strong> will not work but <font style=\"text-decoration: line-through\"><font style=\"text-decoration: line-through\"></font> and <b><b></b> will"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="220" y="0" width="220" height="50" uuid="744bb631-d03a-452e-ae5e-19e7ef5a378a"/>
<textElement markup="html"/>
<textFieldExpression><![CDATA["With java however you can replace'em and both <s><s></s> and <strong><strong></strong> will work".replace("<s>","<font style=\"text-decoration: line-through\">").replace("</s>","</font>").replace("<strong>","<b>").replace("</strong>","</b>")]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
Результат