使用XML数据源在iReport中设置子报表

时间:2010-02-05 06:11:22

标签: xml ireport subreport

任何人都可以详细解释(如果可能,使用屏幕截图)如何添加子报告(一对多关系)

这是xml数据源

<addressbook>
 <category name="home">
  <person id="1">                                                           
      <LASTNAME>Davolio</LASTNAME>
      <FIRSTNAME>Nancy</FIRSTNAME>
      <hobbies>
       <hobby>Radio Control</hobby>
       <hobby>R/C Cars</hobby>
       <hobby>Micro R/C Cars</hobby>
       <hobby>Die-Cast Models</hobby>
      </hobbies>
      <email>email1@my.domain.it</email>
      <email>email2@my.domain2.it</email> 

  </person>
  <person id="2">
      <LASTNAME>Fuller</LASTNAME>
      <FIRSTNAME>Andrew</FIRSTNAME>
      <email>email3@my.domain3.it</email> 
      <email>email4@my.domain4.it</email> 
  </person>
  <person id="3">                                                                 
      <LASTNAME>Leverling</LASTNAME>
      <FIRSTNAME>Janet</FIRSTNAME>
      <hobbies>
       <hobby>Rockets</hobby>
       <hobby>Puzzles</hobby>
       <hobby>Science Hobby</hobby>
       <hobby>Toy Horse</hobby> 
      </hobbies>
      <email>email45@my.domain3.it</email> 
      <email>email455@my.domain4.it</email> 
  </person>
 </category>
 <category name="work">    
  <person id="4">                                                            
      <LASTNAME>Peacock</LASTNAME>
      <FIRSTNAME>Margaret</FIRSTNAME>
      <hobbies>
       <hobby>Toy Horse</hobby> 
      </hobbies>
      <email>Peacock@margaret.com</email>  
  </person>
  <person id="5">
      <LASTNAME>Buchanan</LASTNAME>
      <FIRSTNAME>Steven</FIRSTNAME>
      <hobbies>
      </hobbies>
      <email>Buchanan@steven.com</email>  
  </person>
  <person id="6">
      <LASTNAME>Suyama</LASTNAME>
      <FIRSTNAME>Michael</FIRSTNAME>
  </person>
  <person id="7">
      <LASTNAME>King</LASTNAME>
      <FIRSTNAME>Robert</FIRSTNAME>
  </person>
 </category>
 <category name="Other">    
  <person id="8">   
      <LASTNAME>Callahan</LASTNAME>
      <FIRSTNAME>Laura</FIRSTNAME>
      <email>email25@my.domain3.it</email> 
  </person>
  <person id="9">
      <LASTNAME>Dodsworth</LASTNAME>
      <email>Dodsworth@my.anne.it</email> 
  </person>
 </category>                                                           
</addressbook>

1 个答案:

答案 0 :(得分:0)

此页面正是您所需要的:

http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=48534

基本上有些人试图做你正在做的事情(使用相同的页面和所有内容)并遇到同样的问题。非常棒,他粘贴在他的XML数据源以及他的主和子报告JRXML文件中。查看他的代码以了解他是如何做到的,然后使用&lt; datasourceExpression&gt;语法第二条评论建议让事情顺利进行。