最近作一个项目,第一次用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)); }加上这点代码,搞定,也不须要配置其余东西。