title: How to show JRBeanCollectionDataSource data with help of Table component?
body: <p>I need to show JRBeanCollectionDataSource data in Table component (JasperReports). </p>
  
  <p>Here is my template, ShowPerson.jrxml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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="ShowPerson" pageWidth="612" pageHeight="792" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="304c4c4e-c99a-4399-8081-748d3b7c0b8c"&gt;
      &lt;style name="table"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="1.0" lineColor="#000000"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table_TH" mode="Opaque" backcolor="#F0F8FF"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="#000000"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table_CH" mode="Opaque" backcolor="#BFE1FF"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="#000000"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table_TD" mode="Opaque" backcolor="#FFFFFF"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="#000000"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;subDataset name="Table Dataset 1" whenResourceMissingType="Empty" uuid="63b01547-bce2-47c9-ba15-666f94d11387"&gt;
          &lt;queryString language="SQL"&gt;
              &lt;![CDATA[]]&gt;
          &lt;/queryString&gt;
          &lt;field name="name" class="java.lang.String"/&gt;
          &lt;field name="age" class="java.lang.Integer"/&gt;
      &lt;/subDataset&gt;
      &lt;parameter name="INFO" class="java.lang.String"/&gt;
      &lt;title&gt;
          &lt;band height="40" splitType="Stretch"&gt;
              &lt;staticText&gt;
                  &lt;reportElement uuid="e96450a8-8358-4cae-a094-3add06d57de2" x="0" y="20" width="56" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;&lt;![CDATA[Info]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;textField&gt;
                  &lt;reportElement uuid="e21e9932-ebfe-4bb5-904d-ea99e141866b" x="56" y="20" width="100" height="20"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$P{INFO}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/title&gt;
      &lt;detail&gt;
          &lt;band height="40" splitType="Stretch"&gt;
              &lt;componentElement&gt;
                  &lt;reportElement uuid="dea5d821-81b6-434b-ae27-4f3a0268e805" key="table 1" x="0" y="0" width="572" height="40"/&gt;
                  &lt;jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"&gt;
                      &lt;datasetRun subDataset="Table Dataset 1" uuid="39f8f0bf-8a2b-44f4-9a4c-0c873da79fba"&gt;
                          &lt;datasetParameter name="REPORT_DATA_SOURCE"&gt;
                              &lt;datasetParameterExpression&gt;&lt;![CDATA[]]&gt;&lt;/datasetParameterExpression&gt;
                          &lt;/datasetParameter&gt;
                          &lt;dataSourceExpression&gt;&lt;![CDATA[$P{REPORT_DATA_SOURCE}]]&gt;&lt;/dataSourceExpression&gt;
                      &lt;/datasetRun&gt;
                      &lt;jr:column width="169" uuid="aae649c4-6a69-485f-8a0d-87022df793ee"&gt;
                          &lt;jr:tableHeader height="20" rowSpan="1"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement uuid="795dac43-0ff0-482c-89a0-7dac3b27d513" x="0" y="0" width="169" height="20"/&gt;
                                  &lt;textElement/&gt;
                                  &lt;text&gt;&lt;![CDATA[Name]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:tableHeader&gt;
                          &lt;jr:detailCell height="20" rowSpan="1"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement uuid="4f1ab13a-d776-4cd5-a2a7-a5cf23360816" x="0" y="0" width="169" height="20"/&gt;
                                  &lt;textElement/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{name}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="173" uuid="a6997eea-131e-4555-80e6-a20d4decb18f"&gt;
                          &lt;jr:tableHeader height="20" rowSpan="1"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement uuid="5f6e2413-8025-47ca-9638-9609ea13f93f" x="0" y="0" width="173" height="20"/&gt;
                                  &lt;textElement/&gt;
                                  &lt;text&gt;&lt;![CDATA[Age]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:tableHeader&gt;
                          &lt;jr:detailCell height="20" rowSpan="1"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement uuid="195d51a0-9e45-4201-ad67-d3026ce2e72c" x="0" y="0" width="173" height="20"/&gt;
                                  &lt;textElement/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{age}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                  &lt;/jr:table&gt;
              &lt;/componentElement&gt;
          &lt;/band&gt;
      &lt;/detail&gt;
  &lt;/jasperReport&gt;
  </code></pre>
  
  <p>My POJO:</p>
  
  <pre><code>public class Person {
  
      private String name;
      private int age;
  
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public int getAge() {
          return age;
      }
      public void setAge(int age) {
          this.age = age;
      }
  }
  </code></pre>
  
  <p>Main class for building report:</p>
  
  <pre><code>public class OpenReport {
      public static void main(String[] args) throws JRException {
          Map&lt;String, Object&gt; peopleMap = new HashMap&lt;&gt;();
          peopleMap.put("Sisco", 17);
          peopleMap.put("Eve", 19);
          peopleMap.put("John", 20);
          peopleMap.put("George", 21);
          peopleMap.put("Steve", 18);
  
          ArrayList&lt;Person&gt; dataList = new ArrayList&lt;Person&gt;();
  
          for(Map.Entry&lt;String, Object&gt; personMap : peopleMap.entrySet()) {
              Person person = new Person();
              person.setName(personMap.getKey());
              person.setAge(Integer.valueOf(personMap.getValue().toString()));
              dataList.add(person);
          }
  
          JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataList);
          Map parameters = new HashMap();
          parameters.put("INFO", "Hello");
  
          JasperReport report = (JasperReport) JRLoader.loadObject("src/test/ireport/ShowPerson.jasper");
          JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, beanColDataSource);
  
          JFrame frame = new JFrame("Report");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().add(new JRViewer(jasperPrint));
          frame.pack();
          frame.setVisible(true);
      }
  }
  </code></pre>