Jasper Report不支持所有html标签,支持的标签定义在样式文本示例 http://jasperreports.sourceforge.net/sample.reference/styledtext/index.html
如你看到的<s>
and <strong>
不支持标签。
您的选择是将它们替换为<font style="text-decoration: line-through">
and <b>
如果你喜欢使用html
or
<style isStrikeThrough="true">
and <style isBold="true">
然后使用样式文本而不是 html。
如果有动态数据可以用java来代替
${myField}.replace("<s>","<font style=\"text-decoration: line-through\">").
replace("</s>","</font>").
replace("<strong>","<b>").replace("</strong>","</b>")
如果您需要替换多个标签,我建议在java(静态)中创建一个方法并调用此方法,而不是在报告中执行替换
Example
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>
Result