ireport5.6 using the table component, how to display the JavaBean data source with table

Source: Internet
Author: User
Tags cdata

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.