当前位置: 首页 > 工具软件 > jfinal-admin > 使用案例 >

jfinal导出excel表格插件jfinal-ext使用

易品
2023-12-01

代码示例
package yipin.admin.controller;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.ext.render.excel.PoiRender;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.render.Render;
import com.lyarc.common.controller.BaseController;

import yipin.bean.Exam;

public class PoiRenderController extends BaseController{

public void poiRender(){
    List<Record> list = Db.find("select * from exam");
    String[] header={"id","试题名称","创建时间","更新时间","操作者","是否有效"};
    String[] columns={"id","name","create_time","update_time","operator","is_valid"};
    //其实关键代码就这一句话fileName、sheetName、columns、headers为必须
    Render poirender = PoiRender.me(list).fileName("carInfo.xls").headers(header).sheetName("试题表").columns(columns);
    render(poirender);
}

}

所需jar包(这5个为必须)

com.jfinal
jfinal-ext
3.1.4


com.google.guava
guava
14.0.1


org.jooq
joor
0.9.5


org.apache.poi
poi
3.9


org.apache.poi
poi-ooxml
3.9

 类似资料: