2016-10-22 429 views
0

是否有可能實現類似rowSpan與jasperrepors textfileds?如何拉伸jasperreports子報表,以適應父母身高

我有兩個報告:main和subreport。

在主要細節帶我有文本框和報表:

<band height="15" splitType="Stretch"> 
<property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
<textField isStretchWithOverflow="true" isBlankWhenNull="true"> 
    <reportElement style="cell" stretchType="RelativeToBandHeight" 
        x="20" y="0" width="200" height="15" 
        isPrintWhenDetailOverflows="true"/> 
    <textElement textAlignment="Center" verticalAlignment="Middle"> 
     <font fontName="DejaVu Sans" size="7" isBold="true"/> 
     <paragraph leftIndent="1" rightIndent="1" spacingBefore="1" 
        spacingAfter="1"/> 
    </textElement> 
    <textFieldExpression><![CDATA[$F{org_name}]]></textFieldExpression> 
</textField> 
<subreport> 
    <reportElement stretchType="RelativeToTallestObject" x="220" y="0" 
        width="582" height="15" isPrintWhenDetailOverflows="true"> 
     <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
    </reportElement> 
    <subreportParameter name="SUBREPORT_DIR"> 
     <subreportParameterExpression> 
      <![CDATA[$P{SUBREPORT_DIR}]]> 
     </subreportParameterExpression> 
    </subreportParameter> 
    <dataSourceExpression><![CDATA[$F{EDU_LEVEL_DATASOURCE}]]></dataSourceExpression> 
    <subreportExpression> 
     <![CDATA[$P{SUBREPORT_DIR} 
       + "/reports/scholarship_fund_analysis/sub_education_level.jasper"]]> 
    </subreportExpression> 
</subreport> 

並且在報表的細節帶一個文本框。

目的是爲主報表中的「org_name」textField實現類似rowSpan的操作。當子報表有很多內容時,它工作正常。

當org_name太長,子報表只有很少的行時,就會出現問題。 org_name文本字段的高度大於子報表的總高度。在主報告的下一行之前,子報表下有空餘空間。

結果報告如下:

textfield and subreport

+1

[Jasper report split type]可能的重複(http://stackoverflow.com/questions/39725089/jasper-report-split-type)&[如何增加子報表的textField高度作爲主報表的textField的高度?] (http://stackoverflow.com/q/38767084/876298) –

回答

0

理念:含第一列的文本從報表傳遞參數,以子報表。 在子報表中,在背景帶中顯示此參數,字體顏色爲#FFFFFF(白色)。

怎麼辦呢

我的報告結構: how it looks before

第一列是主報告($ F {daysLabel})。子報表中的第二和第三列。

創建在主報告參數(選擇子報表,1,然後編輯參數,2,如下所示)

how enter a parameter

(I具有小於10分的聲譽,我可以不把)

在打開的窗口中輸入參數名稱(假設爲toto)並且在表達式下,輸入保存列值的變量,在我的情況下爲$ ˚F{daysLab埃爾}。

在報表創建具有相同的名稱,你只是在主報告(TOTO)中創建一個參數,以及要在背景帶顯示。將拉伸溢出條件設置爲true。在我的情況下,這是可以的,因爲第一列的寬度完全符合我的子報告witdh。也許在你的情況下,你可能需要做一個「特殊調整」。

將顏色字體設置爲白色,您會看到您的子報表拉伸與主報表的第一列一樣多。 至於你的細胞在報表邊界,設置bottomPen以0:

<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> 
 
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> 
 
<bottomPen lineWidth="0" lineStyle="Solid" lineColor="#000000"/> 
 
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>

,使得只有上邊界是可見的。

在您的主要報告中,圍繞您的子報告使用具有全部4個邊框的框架。

我的評論(如果你介意):我認爲這是一種討厭的方式。同時,我相信碧玉的引擎會從最內層的子報表渲染到最外層,即主報告。一旦jasper完成最外層的報告,它不會重新渲染內層報告以調整到最外層。我已經與評估時間嘗試了其他比現在自動但文本字段不要再舒展。我也在主要和子報告中嘗試了不同的彈力類型,但沒有運氣。這是我能想出的唯一解決方案。

我會很高興地看到,如果一些已經得到了一個更清潔的解決了這個問題。