JasperReports Embed Data in JRXML without any dataSource

后端 未结 1 1864
一生所求
一生所求 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条回答
  •  -上瘾入骨i
    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

    
                          
    
    

    And the Java Class

    package beandatasource;
    
    import java.util.ArrayList;
    
    public class OnFlyCollection {
    
        public ArrayList ListCollect() {
    
            ArrayList arr_list = new ArrayList();
            arr_list.add("A");
            arr_list.add("B");
            arr_list.add("C");
    
            return arr_list;
        }
    }
    

    0 讨论(0)
提交回复
热议问题