2012-12-18 38 views
1

我正在使用jasper report 5.0.0並創建一個帶有如下所述場景的報告: 在我的ireport中,我需要顯示學生姓名,班級,ID,目標, proficiencyForGoal。每個學生都有多個目標,每個目標都有進步。我的sql查詢如下: 從2或3個表格中選擇stud.name,stud.class,stud.id,prog.goal_id,prog.proficiency,這些表格由prog.goal_id加入並分組。該查詢爲每個學生提供多行。 ireport每行創建多個PDF(使用PDF預覽)。 但我想在單個PDF中顯示所有目標和目標熟練程度以及學生詳細信息,如姓名,班級,ID。那就是我希望每個學生都有一份PDF,其中包含所有的細節。所以如果有500名學生,然後500個pdf。在單個jasperreport中顯示一列中的多條記錄

假設每個學生有10個目標,那麼現在我得到的是一個名稱,班級,身份證重複和500名學生的一名學生的PDF格式我得到500 * 10 = 5000 pdfs這是我不想要的。

欣賞您的快速輸入或有關如何達到此要求的想法。

感謝

回答

1

後你已經添加在您的報告中報告,我認爲只是放置字段(姓名,班級等)的SQL查詢至少應;如果每個學生有多個詳細信息,則可以在報告中爲每個學生使用子報告。

+0

謝謝你的建議。我使用subdataset和datasetrun列表來顯示學生的每個目標標識,而不是subreport。我使用單獨的查詢來獲取subdataset中每個goal_id的熟練程度,如下所示:從prog中選擇熟練程度,其中goal_id = 1和student_id = 1。我想知道如何將主報表查詢中的字段student_id傳遞給子數據集作爲參數,以便我不需要在子數據集中硬編碼student_id。 – JasperNewBie

+0

我不確定有關數據集的信息,但是您可以將主報告中的字段作爲參數傳遞給子報表;有關詳細信息和示例,請參閱此鏈接:http://community.jaspersoft.com/questions/536360/using-field-values-parameter-values-pass-sub-report。 – acostache

0

不知道如何將此添加爲評論,所以我把它放在這裏。

要將值傳遞給您的數據集,它的工作方式與子報表類似,但參數選項不在Ireport的屬性部分。
就像在一個報表,你首先需要一個參數添加到您的數據集(student_id數據)

然後才能到參數屏幕上,您需要:

右鍵單擊列表 上選擇「編輯列表數據源」 在參數標籤下點擊「添加」 進入頂部拉你將擁有你的數據集參數(student_id)[你只會從你的數據集中獲得一個有效參數列表] 在值表達式中你將擁有你的主數據報告$F{student_id}

這將通過從您的主報告中student_id數據到數據集(用於名單的,表的和交叉的)

的那麼五言的,你需要添加到您的數據集的where子句

where $P{student_id} = student_id

0

在查詢您可以student_id數據

Like: where student_id=$P{p_student_id} 

添加參數化的條件,並保持在總結樂隊的一切,如文本字段和靜態文本。

0

假設您的查詢是由學生命令的一種更簡單的方法。 在Ireport添加一個羣組(在報告督察右鍵點擊「添加報告組」) 你很可能不需要頁眉或頁腳 放下所有的領域(名稱,職業,ID,goal_id,熟練度) 您可能希望聯合國點擊名稱,類別上的「打印重複值」屬性,編號爲 選擇您的組(在報告檢查員中) 選擇「在新頁面上開始」(您可能還想重置頁面並重新打印頁眉) 也「保持在一起」

這裏有一個例子,你需要把你的查詢爲它在所有

<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="report9" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5ac8f93f-0f1f-4f1c-8c7c-41a15b76ef65"> 
<?xml version="1.0" encoding="UTF-8"?> 
    <property name="ireport.zoom" value="1.0"/> 
    <property name="ireport.x" value="0"/> 
    <property name="ireport.y" value="0"/> 
    <queryString> 
     <![CDATA[select sysdate from dual ]]> 
    </queryString> 
    <field name="name" class="java.lang.String"/> 
    <field name="class" class="java.lang.String"/> 
    <field name="id" class="java.lang.String"/> 
    <field name="goal_id" class="java.lang.String"/> 
    <field name="proficiency" class="java.lang.String"/> 
    <group name="Student Name" isStartNewPage="true" isResetPageNumber="true" isReprintHeaderOnEachPage="true" keepTogether="true"> 
     <groupExpression><![CDATA[$F{name}]]></groupExpression> 
    </group> 
    <background> 
     <band splitType="Stretch"/> 
    </background> 
    <title> 
     <band height="79" splitType="Stretch"/> 
    </title> 
    <pageHeader> 
     <band height="35" splitType="Stretch"/> 
    </pageHeader> 
    <columnHeader> 
     <band height="20" splitType="Stretch"> 
      <staticText> 
       <reportElement uuid="b78d9294-5efc-4d3a-a08b-749493ecf242" x="0" y="0" width="111" height="20"/> 
       <textElement/> 
       <text><![CDATA[name]]></text> 
      </staticText> 
      <staticText> 
       <reportElement uuid="8eeacd33-15c4-416e-981e-f8aac2586443" x="111" y="0" width="111" height="20"/> 
       <textElement/> 
       <text><![CDATA[class]]></text> 
      </staticText> 
      <staticText> 
       <reportElement uuid="dc878516-ecc7-405d-a288-ead78229e564" x="222" y="0" width="111" height="20"/> 
       <textElement/> 
       <text><![CDATA[id]]></text> 
      </staticText> 
      <staticText> 
       <reportElement uuid="0eb5c805-4358-4d85-b567-d513a318a54d" x="333" y="0" width="111" height="20"/> 
       <textElement/> 
       <text><![CDATA[goal_id]]></text> 
      </staticText> 
      <staticText> 
       <reportElement uuid="b9675b06-87ac-4441-a207-0cbd58dbf925" x="444" y="0" width="111" height="20"/> 
       <textElement/> 
       <text><![CDATA[proficiency]]></text> 
      </staticText> 
     </band> 
    </columnHeader> 
    <detail> 
     <band height="20" splitType="Stretch"> 
      <textField> 
       <reportElement uuid="b284aaa5-475e-4b54-a1bd-ce4772cf79a2" isPrintRepeatedValues="false" x="0" y="0" width="111" height="20"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement uuid="80f38abc-1cb3-41c0-a9c6-2473e84a8c6d" isPrintRepeatedValues="false" x="111" y="0" width="111" height="20"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$F{class}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement uuid="30a371f8-4d08-4125-8e85-497b2697e9d3" x="222" y="0" width="111" height="20"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement uuid="53757283-0c03-4248-9848-1eba9ee168b7" x="333" y="0" width="111" height="20"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$F{goal_id}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement uuid="3d2bbbc0-0fe1-4442-809f-acee606db5ac" x="444" y="0" width="111" height="20"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$F{proficiency}]]></textFieldExpression> 
      </textField> 
     </band> 
    </detail> 
    <columnFooter> 
     <band height="45" splitType="Stretch"/> 
    </columnFooter> 
    <pageFooter> 
     <band height="54" splitType="Stretch"/> 
    </pageFooter> 
    <summary> 
     <band height="42" splitType="Stretch"/> 
    </summary> 
</jasperReport> 
工作
相關問題