2013-07-03 51 views
0

我正在使用ireport-4.5.0,jasper-reports-4.5.0.I試圖將邊框添加到列標題。雖然我使用Google搜索,我們可以使用矩形獲得邊框。我使用了矩形,但沒有獲得邊框。下面是我正在使用的代碼。如何使用矩形獲取我的報告列標題的邊框

<columnHeader> 
     <band height="39" splitType="Stretch"> 
      <rectangle> 
       <reportElement x="131" y="0" width="424" height="39"/> 
      </rectangle> 
      <rectangle> 
       <reportElement x="0" y="1" width="131" height="38"/> 
      </rectangle> 
      <staticText> 
       <reportElement x="11" y="16" width="108" height="14"/> 
       <textElement> 
        <font size="12" isBold="true"/> 
       </textElement> 
       <text><![CDATA[Business Name]]></text> 
      </staticText> 
      <staticText> 
       <reportElement x="154" y="10" width="361" height="20"/> 
       <textElement textAlignment="Center"> 
        <font size="12" isBold="true"/> 
       </textElement> 
       <text><![CDATA[Sales Report]]></text> 
      </staticText> 
     </band> 
    </columnHeader> 

任何一個人能指出我正確的方向,我犯了錯誤。

在此先感謝。

+1

你可以看一下[在JasperReports中添加表格邊框](http://stackoverflow.com/q/10278067/876298)發佈 –

+0

嗨亞歷克斯,我不想使用填充和邊界。我只需要使用矩形。我編輯了我原來的問題。 – NSS

+0

Bcoz我需要將邊框添加到子報表中。我認爲我們沒有用於子報表的填充和邊框。所以我只需要使用矩形。 – NSS

回答

2

問題是矩形需要比場稍大。如果您想到圖層,則文本框位於矩形的頂部,這就是爲什麼您看不到矩形。使用邊框效果更好。只需右鍵單擊對象並轉到「填充和邊框」

<columnHeader> 
    <band height="20" splitType="Stretch"> 
     <staticText> 
      <box> 
       <pen lineWidth="0.5"/> 
       <topPen lineWidth="0.5"/> 
       <leftPen lineWidth="0.5"/> 
       <bottomPen lineWidth="0.5"/> 
       <rightPen lineWidth="0.5"/> 
      </box> 
      <textElement> 
       <font size="12" isBold="true"/> 
      </textElement> 
      <text><![CDATA[Business Name]]></text> 
     </staticText> 
     <staticText> 
      <box> 
       <pen lineWidth="0.5"/> 
       <topPen lineWidth="0.5"/> 
       <leftPen lineWidth="0.5"/> 
       <bottomPen lineWidth="0.5"/> 
       <rightPen lineWidth="0.5"/> 
      </box> 
      <textElement textAlignment="Center"> 
       <font size="12" isBold="true"/> 
      </textElement> 
      <text><![CDATA[Sales Report]]></text> 
     </staticText> 
    </band> 
</columnHeader> 
+0

嗨Mnoland.I不想使用填充和邊界。我需要使用矩形Only.I已嘗試通過給矩形尺寸大於該字段。但我仍然沒有得到邊界。我已編輯我的原始問題。你可以看看它,謝謝 – NSS

0

對每個靜態文本字段使用兩個矩形。 試試這個,但我確實只針對中心的文本: -

<columnHeader> 
    <band height="39" splitType="Stretch"> 
     <rectangle> 
      <reportElement x="131" y="0" width="424" height="39" backcolor="#FF6666"/> 
     </rectangle> 
     <rectangle> 
      <reportElement x="134" y="3" width="419" height="31"/> 
     </rectangle> 
     <staticText> 
      <reportElement x="154" y="10" width="361" height="20"/> 
      <textElement textAlignment="Center"> 
       <font size="12" isBold="true"/> 
      </textElement> 
      <text><![CDATA[Sales Report]]></text> 
     </staticText> 
    </band> 
</columnHeader>