2016-02-26 223 views
1

我有一個只有一個文本字段的子報表。該文本字段可以包含從服務檢索到的約5000個字符。在子報表中,「Stretch with overflow」可以跨越多個頁面嗎?

我的目標是在父報告中顯示此子報表。它應該從「Float」位置開始,我將它放置在多個頁面上。

當我有這個報表在我父母的報告中,文本剪輯在報表文本字段的「溢出拉伸」設置爲。 當我將「Stretch with overflow」設置爲true時,文本字段在頁面上顯示爲空白,但佔用父級報告上的所需空間。

我曾嘗試以下,但沒有似乎工作:

1.在子報告:

  • 打印細節時溢出=真
  • 分體式=「拉伸「
  • Ignore pagination = true

2.主要報告:

  • 分體式= 「拉伸」
  • 打印時詳細溢出=報表對象
  • 打印在第一全頻帶=真上真正

嘗試它,因爲幾天讓我覺得它是不可能的在頁面之間有一個溢出的文本字段。

請讓我知道,如果它甚至可能有一個帶有文本字段的子報告跨越多個頁面。

回答

1

「它甚至可能有一個帶有文本字段的子報表來跨越多個頁面?」

是的,我在下方附上

主報告爲例

<?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="stretchTest" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="BlankPage" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6c8cebac-a7b5-4dc2-abe8-e36b0cb184ca"> 
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> 
     <defaultValueExpression><![CDATA["C:\\jdd\\projects\\StackTrace\\jasper\\"]]></defaultValueExpression> 
    </parameter> 
    <detail> 
     <band height="20" splitType="Stretch"> 
      <subreport> 
       <reportElement x="0" y="0" width="100" height="20" uuid="778b107f-288e-4f17-915d-fed6f83a2805"/> 
       <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource(2)]]></dataSourceExpression> 
       <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "stretchTest_subreport.jasper"]]></subreportExpression> 
      </subreport> 
     </band> 
    </detail> 
</jasperReport> 

子報表

<?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="stretchTest_subreport" pageWidth="100" pageHeight="555" orientation="Landscape" columnWidth="100" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="f716e850-ab6f-4668-b3a1-afe4823b8abf"> 
    <property name="ireport.zoom" value="1.0"/> 
    <property name="ireport.x" value="0"/> 
    <property name="ireport.y" value="0"/> 
    <parameter name="veryLongTextThatNeedToBreak" class="java.lang.String" isForPrompting="false"> 
     <defaultValueExpression><![CDATA["I have a subreport with just one text field. This text field can have somewhere around 5000 characters retrieved from a service. My goal is to show this subreport on the parent report.(it should start from the Float position where I place it to multiple pages in a continuous manner). When I have this subreport in my parent report, the text clips when the Stretch with overflow of the text field in subreport is set to false. When I set Stretch with overflow to true, the text field appears blank on the pages but takes up the required space on the parent report. I have tried the following but nothing seem to work:1. In the sub report: Set the Print when detail overflow = true Set Split Type = Stretch Ignore pagination = true 2. Main report: Set Split Type = Stretch Set Print when detail overflow = true of subreport object Print in first whole band = true Trying it since few days has made me feel that it is impossible to have a overflowing text field across pages. Please let me know if its even possible to have a subreport with text field to span across multiple pages. Thanks in advance!!"]]></defaultValueExpression> 
    </parameter> 
    <detail> 
     <band height="20" splitType="Stretch"> 
      <textField isStretchWithOverflow="true"> 
       <reportElement x="0" y="0" width="100" height="20" uuid="4f14a231-dd62-465b-b10a-fa39f9c6a297"/> 
       <textFieldExpression><![CDATA[$P{veryLongTextThatNeedToBreak}]]></textFieldExpression> 
      </textField> 
     </band> 
    </detail> 
</jasperReport> 

編譯報表,設置爲子報表並測試你自己正確的路徑。

注意:我沒有在reportElement上設置很多屬性。

輸出

output

+0

只是寫這一點,如果它可以幫助任何人的未來。我爲子報表中的子報表和元素設置了太多屬性。要設置的屬性的確切集合如下: 父報告: 1.波段拆分類型=拉伸。 2.子報表元素拉伸類型=無拉伸 子報表: 1.對於文本字段,使用overflow = true的Stretch。 2.拉伸類型=沒有拉伸 3.波段,分割類型=拉伸 – dnaik

+0

是的,我正在想象這個,你陷入了一片混亂,當你試圖離開時你陷入了更多,爲什麼我發佈了一個簡單的例子試圖打破你的懷疑......:)感謝您接受.. –

相關問題