JFinal-ext 導出excel 實例筆記

最近作一個項目,第一次用jfinal框架,在此感謝Jfinal團隊的貢獻,讓快速開發再也不是夢想。也感謝JFE團隊,讓咱們操做office再也不須要作更多事情。 框架

在這裏記錄一下,使用JFinal-ext 導出excel,的例子吧。 google

首先固然是導入jar包了。
一、jfinal-ext-3.1.2.jar spa

二、poi-3.8-20120326.jar excel

三、google-collections-1.0.jar code

開始,想找一下關於JFE的相應demo,可是最後仍是沒有找到合適的,最後看了一下源碼。發現真的很簡單而後就動手了。 開發

有了上面3個包。 get

public void export_pbmb(){
    String id = getPara("id");  String[] columns = new String[] { "id", "dep_name", "class_name","student_name","student_sb_cart","student_id_cart" };  String[] headers2 = new String[] { "ID", "學校", "班級","學生姓名","社保卡號","身份證","准考證號","地點","試室","座位號","時間","理論考試地點","理論考試試室","理論考試座位號","理論考試時間","實操考試地址","實操考試試室","實操實操考試座位號","實操考試時間"};  List<Record> data = Db.find("select s.id,d.dep_name,c.class_name,s.student_name,s.student_sb_cart,s.student_id_cart from bk_project_student s,bk_class c,sys_department d where s.class_id=c.id and s.dep_id=d.id and s.project_id="+id);   render(PoiRender.me(data).fileName("text.xls").columns(columns).headers(headers2)); }
加上這點代碼,搞定,也不須要配置其餘東西。
相關文章
相關標籤/搜索