1. Add a table component to the report from the palette.
2. Design the field header for the table.
Merge operations
1.
2.
Delete columns that you don't need
Add your merge columns
3. add a parameter to the report parameters Dets (java.util.List)
4. Configure the table data set
A. Re-command data set (convenient)
Right-the "property can be modified.
B. Add a parameters
Add a table1 (net.sf.jasperreports.engine.JRDataSource)
C. manually configure the code to pass the Dets parameter to the Table1 receive
<datasetparameter name= "table1" ><datasetparameterexpression><! [Cdata[new Net.sf.jasperreports.engine.data.JRBeanCollectionDataSource ($P {dets})]]></ datasetparameterexpression></datasetparameter><datasourceexpression><! [Cdata[new Net.sf.jasperreports.engine.data.JRBeanCollectionDataSource ($P {dets})]]></datasourceexpression >
D. adding fields, displaying the field
5. Report Design Complete
6. Write Java code to pass the JavaBean data source in a way that invokes the report and displays
/** * Print Report Ckz * * @param billcode * @param req * @param resp * @throws Exception */@ Suppresswarnings ({"Rawtypes", "Unchecked"}) @Transactional (readOnly = true) public void DoReport (String billcode,s Tring exporttype,httpservletrequest request,httpservletresponse response) {try {String Root_path = requ Est.getsession (). Getservletcontext (). Getrealpath (""); List List = Binadjustbillmasdao.querybinadjustbillds (Billcode); List DataList = Binadjustbilldetdao.querybinadjustbilldet (Billcode); Set the report parameter Map params = new HashMap (); String username = (string) request.getsession (). getattribute ("EmployeeName"); Params.put ("username", username); Params.put ("title", "Material adjustment list"); Params.put ("Dets", DataList); Params.put ("Subreport_dir", Root_path + "\\webresource\\reports\\binadjust\\"); Params.put ("logo", Root_path + Ireportconstant.logoimageurl); Gets the data required to print the report String jaspername = "/binadjust/report_binadjustbill_mas_cn.jasper"; Note: The size of the list, the decision to determine the detail display several times, such as: size=2, then the loaded report will have 2 table display Jasperhelper.exportmain (Exporttype, Jaspername , list, params, "binadjust", request, response); } catch (Exception ex) {printwriter out = null; try {response.setcharacterencoding ("UTF-8"); out = Response.getwriter (); Out.write ("7. Effect
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
ireport5.6 using the table component, how to display the JavaBean data source with table