Jasper reports 无法查看jasper报表中列标题中的文本

Jasper reports 无法查看jasper报表中列标题中的文本,jasper-reports,export-to-pdf,Jasper Reports,Export To Pdf,我正在尝试创建一个jasper报告(pdf格式),其中显示已处理的呼叫列表。正在创建报告,但未显示标题。我曾试图改变风格,但在这个案例中似乎没有任何效果 我正在为此使用以下LIB - jasper-compiler-jdt-5.5.15.jar - jasperreports-6.2.0.jar - jasperreports-fonts-6.0.0.jar - itext-2.1.7.jar - itextpdf-5.5.10.jar 以下是jrxml文件的一部

我正在尝试创建一个jasper报告(pdf格式),其中显示已处理的呼叫列表。正在创建报告,但未显示标题。我曾试图改变风格,但在这个案例中似乎没有任何效果

我正在为此使用以下LIB

-    jasper-compiler-jdt-5.5.15.jar
-    jasperreports-6.2.0.jar
-    jasperreports-fonts-6.0.0.jar
-    itext-2.1.7.jar
-    itextpdf-5.5.10.jar
以下是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="StockReport" pageWidth="1200" pageHeight="600" columnWidth="50" leftMargin="35" rightMargin="35" topMargin="50" bottomMargin="40">

<parameter name="Title" class="java.lang.String"/>


<field name="id" class="java.lang.Long"/>
<field name="dateTime" class="java.util.Date"/>

 --------------------------------------------------

<title>
<band height="50" splitType="Stretch">
    <textField isBlankWhenNull="true">
        <reportElement x="0" y="5" width="960" height="30"/>
            <textElement textAlignment="Center">

            </textElement>
            <textFieldExpression class="java.lang.String"><![CDATA[$P{Title}]]>    
            </textFieldExpression>
   </textField>
</band>
</title>
<pageHeader>
<band height="20" splitType="Stretch">
    <textField>
        <reportElement mode="Opaque" x="55" y="5" width="1000" height="15" forecolor="#FFFFFF" backcolor="#8c8c8c"/>
        <textElement textAlignment="Center">
        </textElement>
        <textFieldExpression class="java.lang.String"><![CDATA["Daily Reports"]]></textFieldExpression>
    </textField>
</band>
</pageHeader>
<columnHeader>
   <band height="20" splitType="Stretch">
    <staticText>
        <reportElement mode="Opaque" x="55" y="4" width="30" height="15" forecolor="#FFFFFF" backcolor="#b30000"/>
        <textElement textAlignment="Left">
            <font isBold = "true"/>
        </textElement>
        <text>
            <![CDATA["Record Id"]]>
        </text>
    </staticText>
    <staticText>
         <reportElement positionType="Float" mode="Opaque" x="85" y="4" width="100" height="15" forecolor="#FFFFFF" backcolor="#b30000"/>
        <textElement>
            <font isBold = "true"/>
        </textElement>
        <text>
            <![CDATA["Date/Time"]]>
         </text>
    </staticText>

 -------------------------------------------


 </band>
</columnHeader>
<detail>
   <band height="80" splitType="Stretch">
    <textField>
        <reportElement x="65" y="4" width="15" height="60"/>
    <textElement textAlignment="Left"/>
        <textFieldExpression class="java.lang.Long"><![CDATA[$F{id}]]>
        </textFieldExpression>
    </textField>
    <textField isStretchWithOverflow="true">
        <reportElement positionType="Float" x="95" y="4" width="90" height="60"/>
    <textElement/>
    <textFieldExpression class="java.util.Date"><![CDATA[$F{dateTime}]]></textFieldExpression>
</textField>

 -----------------------------------------------------
生成的pdf的屏幕截图(一些细节已被删除)

我们将非常感谢您的帮助

我没有使用iReport工具。目前,该产品仅限本集团使用。请提出除此之外的解决方案


提前感谢。

感谢所有帮助过你的人

问题与itext无关,而是与元素样式有关

更新后的代码如下

  <?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="StockReport" pageWidth="1200" pageHeight="600" columnWidth="50" leftMargin="35" rightMargin="35" topMargin="50" bottomMargin="40">

<parameter name="Title" class="java.lang.String"/>


<field name="id" class="java.lang.Long"/>
<field name="dateTime" class="java.util.Date"/>


--------------------

<title>
<band height="50" splitType="Stretch">
<textField isBlankWhenNull="true">
    <reportElement x="0" y="5" width="960" height="30"/>
    <textElement textAlignment="Center">
    </textElement>
    <textFieldExpression class="java.lang.String"><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
 </band>
 </title>
 <pageHeader>
 <band height="20" splitType="Stretch">
<textField>
    <reportElement mode="Opaque" x="55" y="5" width="1000" height="15" forecolor="#FFFFFF" backcolor="#8c8c8c"/>
    <textElement textAlignment="Center">
    </textElement>
    <textFieldExpression class="java.lang.String"><![CDATA["Daily Reports"]]></textFieldExpression>
</textField>
 </band>
 </pageHeader>
    <columnHeader>
  <band height = "23">

     <staticText>
        <reportElement mode = "Opaque" x = "55" y = "3" 
           width = "1000" height = "15" backcolor = "#70A9A9" />

        <box>
           <bottomPen lineWidth = "1.0" lineColor = "#CCCCCC" />
        </box>

        <textElement />
        <text><![CDATA[]]> </text>
     </staticText>

-------------------------------------


     <staticText>
        <reportElement x = "85" y = "3" width = "100" height = "15" />

        <textElement textAlignment = "Center" verticalAlignment = "Middle">
           <font isBold = "true" />
        </textElement>

        <text><![CDATA[Date/Time]]></text>
     </staticText>

     <staticText>
        <reportElement x = "55" y = "3" width = "30" height = "15" />

        <textElement textAlignment = "Center" verticalAlignment = "Middle">
           <font isBold = "true" />
        </textElement>

        <text><![CDATA[#Id]]></text>
     </staticText>

  </band>

--------------------
-------------------------------------

我所做的只是添加了一个元素,没有文本内容用作列标题横幅,并通过指定位置将标题文本添加到其顶部

我不确定这背后的逻辑。至于警告,找到的
未修补的iText无法使用glyph呈现
仍然存在。我不知道如何解决这个问题,但上面提到的帮助我解决了最初的问题。如果有人遇到类似的问题,我希望这会有所帮助


再次感谢所有帮助过我的人,正如上面评论中所建议的,我将尝试对更新的库做同样的事情,如果有助于解决问题,我一定会用更新的结果编辑我的文章

你的问题不清楚<代码>正在创建报告,但未显示标题。-这是什么意思?它是空白的还是显示的是
?还是跳过了区域?你是如何检查结果的(pdf,xls)?您正在使用字体扩展吗?1)尝试删除
reportFont
行(示例中第三行);2) 尝试使用jasperreports-fonts-6.0.0.jar中的字体;3) 尝试使用样式并在列标题处使用样式。您的问题之一是您正在混合iText版本。不,“iText”和“itextpdf”是完全相同的产品。可用的最新版本是7.0.3,但这是一个完全重写,不向后兼容。最新版本仍然与您的代码兼容,是今年3月发布的5.5.11。2.1.7(2009年7月发布)是一个弃用版本,公司iText软件不再支持该版本。披露:我在那里做QA工程师,所以我有权威人士的观点。显然Jasper Reports期望的是旧版本的iText,而不是新版本。
  <?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="StockReport" pageWidth="1200" pageHeight="600" columnWidth="50" leftMargin="35" rightMargin="35" topMargin="50" bottomMargin="40">

<parameter name="Title" class="java.lang.String"/>


<field name="id" class="java.lang.Long"/>
<field name="dateTime" class="java.util.Date"/>


--------------------

<title>
<band height="50" splitType="Stretch">
<textField isBlankWhenNull="true">
    <reportElement x="0" y="5" width="960" height="30"/>
    <textElement textAlignment="Center">
    </textElement>
    <textFieldExpression class="java.lang.String"><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
 </band>
 </title>
 <pageHeader>
 <band height="20" splitType="Stretch">
<textField>
    <reportElement mode="Opaque" x="55" y="5" width="1000" height="15" forecolor="#FFFFFF" backcolor="#8c8c8c"/>
    <textElement textAlignment="Center">
    </textElement>
    <textFieldExpression class="java.lang.String"><![CDATA["Daily Reports"]]></textFieldExpression>
</textField>
 </band>
 </pageHeader>
    <columnHeader>
  <band height = "23">

     <staticText>
        <reportElement mode = "Opaque" x = "55" y = "3" 
           width = "1000" height = "15" backcolor = "#70A9A9" />

        <box>
           <bottomPen lineWidth = "1.0" lineColor = "#CCCCCC" />
        </box>

        <textElement />
        <text><![CDATA[]]> </text>
     </staticText>

-------------------------------------


     <staticText>
        <reportElement x = "85" y = "3" width = "100" height = "15" />

        <textElement textAlignment = "Center" verticalAlignment = "Middle">
           <font isBold = "true" />
        </textElement>

        <text><![CDATA[Date/Time]]></text>
     </staticText>

     <staticText>
        <reportElement x = "55" y = "3" width = "30" height = "15" />

        <textElement textAlignment = "Center" verticalAlignment = "Middle">
           <font isBold = "true" />
        </textElement>

        <text><![CDATA[#Id]]></text>
     </staticText>

  </band>