jfinal框架批量导出数据到Excel
1.配置controller
| public void export(){ ?? ??? ?Map<String, String[]> searchMap = new HashMap<String,String[]>(getParaMap()); ?? ??? ?String sql = "select b.name,b.sex,b.card_number,b.address,b.lxdh,b.check_flag,b.sjly,d.value jflx,c.name jfdd,o.je,o.jfnf,o.lrr,o.create_time,e.value yhlx from zklt_sjjl o,zklt_id_card_info b,zklt_area c,sys_dct d,sys_dct e,sys_user f where o.sfzh=b.card_number and o.jfdd=c.id and o.jflx=d.key and b.yhlx=e.key and o.creater=f.id and d.group_id='82088c59e3584c27830c8a831d355150' and e.group_id='93bfd0284e0e47ddaf4f08f429b691d1' and f.status=1 and o.yxbs='1' and b.yxbs='1' and c.yxbs='1' "; ?? ??? ?String[] colCode =new String[] {"name","sex","card_number","address","jflx","jfdd","je","lrr","create_time","yhlx","lxdh","sjly"}; ?? ??? ?String[] colName = new String[] {"姓名","性別", "身份證號", "地址", "繳費(fèi)類型", "繳費(fèi)地點(diǎn)", "金額", "填報人", "填報日期", "備注","聯(lián)系電話","數(shù)據(jù)來源","說明"}; ? ? ? ? File file = new File(ExcelExportUtil.getTitle()); ?? ? ? ?file = ExcelExportUtil.saveFile(colCode,colName, sql, file); ?? ? ? ?renderFile(file); ?? ?} |
2.controller中使用的工具類:
| ? import java.io.File; import org.apache.poi.hssf.usermodel.HSSFCell; import com.jfinal.kit.PathKit; public class ExcelExportUtil { //設(shè)置第2行第13列單元格的內(nèi)容 |
3.頁面HTML按鈕
| <form action="#(ctx)/admin/zklt/payInfo/export" method="post"> ?? ??? ??? ??? ??? ??? ?<div class="form-group"> ?? ??? ??? ??? ??? ??? ??? ?<div class="col-md-3"> ?? ??? ??? ??? ??? ??? ??? ??? ?<label class="col-sm-5 control-label">繳費(fèi)年份</label> ?? ??? ??? ??? ??? ??? ??? ??? ?<div class="col-sm-7"> ?? ??? ??? ??? ??? ??? ??? ??? ??? ?<input type="text" id="ssnf" name="ssnf" value="#(ssnf?ssnf:'')" class="form-control" readonly="readonly" ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?onFocus="WdatePicker({isShowClear:false,dateFmt:'yyyy',startDate:'%y'})">? ?? ??? ??? ??? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ??? ?<div class="form-group"> ?? ??? ??? ??? ??? ??? ??? ?<div class="col-md-3"> ?? ??? ??? ??? ??? ??? ??? ??? ?<label class="col-sm-5 control-label">身份證號</label> ?? ??? ??? ??? ??? ??? ??? ??? ?<div class="col-sm-7"> ?? ??? ??? ??? ??? ??? ??? ??? ??? ?<input id="sfzh" name="sfzh" class="form-control" type="text"> ?? ??? ??? ??? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ??? ?<div class="form-group"> ?? ??? ??? ??? ??? ??? ??? ?<div class="col-md-9 text-right"> ?? ??? ??? ??? ??? ??? ??? ??? ?<button class="btn btn-mint" type="button" οnclick="refreshTable();"><i class="glyphicon glyphicon-search"></i> 搜索</button> ?? ??? ??? ??? ??? ??? ??? ??? ?<button class="btn btn-mint" type="submit"><i class="glyphicon glyphicon-arrow-up"></i> 導(dǎo)出</button> ?? ??? ??? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ?</form> |
?
總結(jié)
以上是生活随笔為你收集整理的jfinal框架批量导出数据到Excel的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 实现双击事件
- 下一篇: oracle获取当前日期的前一天,判断两