1.bean
$ cat databean.java public class databean { private String first_name ; public void setFirst_name(String name) { first_name = name; } public String getFirst_name() { return(first_name); } }2.bean生成
$ cat databean.java public class databean { private String first_name ; public void setFirst_name(String name) { first_name = name; } public String getFirst_name() { return(first_name); } }3.帳票作成
import java.util.*; import net.sf.jasperreports.engine.*; import net.sf.jasperreports.engine.data.*; class sample01 { @SuppressWarnings("unchecked") public static void main(String[] args) { databeanlist db = new databeanlist(); ArrayList4.コンパイルdblist = db.getdatabeanlist(); JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dblist); Map parameters = new HashMap(); try { JasperFillManager.fillReportToFile( "sample01.jasper", "sample01.jrprint", parameters, beanColDataSource); } catch (JRException e) { e.printStackTrace(); } } }
$ javac sample01.java $ ls databean.class databeanlist.class jrc.class sample01.class sample01.java databean.java databeanlist.java jrc.java sample01.jasper sample01.jrxml5。実行(.jrprint作成)
$ java sample01 databean.class databeanlist.java sample01.class sample01.jrprint databean.java jrc.class sample01.jasper sample01.jrxml databeanlist.class jrc.java sample01.java6。印刷イメージ確認
$ java net.sf.jasperreports.view.JasperViewer test01.jrprint
0 件のコメント:
コメントを投稿