java - How to add JRBeanCollectionDataSource data into table of content in Jasper Report? -


i have data in jrbeancollectiondatasource. want add data table of content in jasper report. tried unable map structure. have added code below reference.

arraylist<studentdetails> studentreportlist = new arraylist<studentdetails>(); studentreportlist = getstudentreportlist(); jasperreport jasperreport = null; jasperprint jasperprint = null; hashmap<string, object> reportparms = new hashmap<string, object>(); jasperdesign jasperdesign = jrxmlloader.load("studentreport.jrxml"); jasperreport = jaspercompilemanager.compilereport(jasperdesign); jrbeancollectiondatasource beancoldatasource = new jrbeancollectiondatasource(studentreportlist); jasperprint = jasperfillmanager.fillreport(jasperreport,reportparms,beancoldatasource); 

please find studentreport.xml file

<?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="alarmreport" pagewidth="595" pageheight="842" columnwidth="535" leftmargin="30" rightmargin="30" topmargin="30" bottommargin="30" whenresourcemissingtype="empty">     <querystring>         <![cdata[]]>     </querystring>     <field name="studentname" class="java.lang.string">         <fielddescription><![cdata[studentname]]></fielddescription>     </field>     <title>             <band height="23">                 <statictext>                     <reportelement x="10" y="5" width="150" height="15"/>                     <textelement textalignment="left" verticalalignment="middle">                         <font isbold="true"/>                     </textelement>                     <text><![cdata[student name]]></text>                 </statictext>             </band>     </title>     <detail>         <band height="23">             <textfield>                 <reportelement x="10" y="5" width="150" height="15"/>                 <textelement textalignment="left" verticalalignment="middle"/>                 <textfieldexpression class="java.lang.string"><![cdata[$f{studentname}]]></textfieldexpression>             </textfield>         </band>     </detail> </jasperreport> 

i want display in table of content using unable add inside table element.

 <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">                                 <datasetrun subdataset="table dataset 3" uuid="e10fc76c-07f0-4640-ae0c-fd7e66f5991e">                                     <datasourceexpression><![cdata[new net.sf.jasperreports.engine.jremptydatasource(1)]]></datasourceexpression>                                 </datasetrun>                                 <jr:column width="66" uuid="b19fb361-d61a-4633-a23a-3e714f93381f">                                     <jr:tableheader style="table 2_th" height="17" rowspan="1">                                         <statictext>                                             <reportelement uuid="ab2cac92-a59b-4278-b5d9-31ed50d98918" x="0" y="0" width="66" height="17"/>                                             <textelement verticalalignment="middle">                                                 <font size="8" isbold="true"/>                                             </textelement>                                             <text><![cdata[student name]]></text>                                         </statictext>                                     </jr:tableheader>                                     <jr:detailcell style="table 2_td" height="16" rowspan="1">                                         <textfield>                                             <reportelement uuid="5736bf99-52c4-4787-a223-a3d931c13b4b" x="0" y="0" width="66" height="16"/>                                             <textelement/>                                             <textfieldexpression><![cdata[$f{studentname}]]></textfieldexpression>                                         </textfield>                                     </jr:detailcell>                                   </jr:column>                         </jr:table>                     </componentelement>                 </band>             </detail>         </jasperreport> 

it getstudentreportlist() returns empty list, detail bands not printed.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -