JasperReports Embed Data in JRXML without any dataSource

后端 未结 1 1865
一生所求
一生所求 2021-01-06 18:45

I want to embed data in report template(jrxml) without any dataSource.I want to write my data staticly in jrxml,аnd display the table with this data. It is really possible?<

相关标签:
1条回答
  • 2021-01-06 19:07

    You can have a list variable and store the data in it using Java class.

    1. Create a variable with variable class list or collection.
    2. Put in the variable expression the Java method which returns the list.

    If you are using groovy same thing can be achieved Groovy Collection. Here's more if you want to learn about groovy collections .

    For Example :

    Have a parameter/variable in report

    <parameter name="list_collect" class="java.util.List" isForPrompting="false">
      <defaultValueExpression><![CDATA[(new beandatasource()).OnFlyCollection()]]>                    </defaultValueExpression>
    </parameter>
    

    And the Java Class

    package beandatasource;
    
    import java.util.ArrayList;
    
    public class OnFlyCollection {
    
        public ArrayList<String> ListCollect() {
    
            ArrayList<String> arr_list = new ArrayList<String>();
            arr_list.add("A");
            arr_list.add("B");
            arr_list.add("C");
    
            return arr_list;
        }
    }
    
    0 讨论(0)
提交回复
热议问题