java导出Excel
程序员文章站
2022-03-15 12:58:18
...
Controller层:
@RequestMapping("/export")
@ResponseBody
publicCommonStatusexport(Companybean,HttpServletRequestrequest,HttpServletResponseresponse){
ExcelUtil<Company>util=newExcelUtil<Company>(Company.class);
//可以设置条件
List<Company>list=this.service.export(null);
ByteArrayOutputStreamout=newByteArrayOutputStream();
StringfileName="入孵入驻公司信息.xls";
util.exportExcel(list,fileName,out);//导出
download(fileName,out,response);
returnsuccess();
}
mapper.xml
<!--导出-->
<selectid="export"resultMap="companyResultMap"parameterType="java.util.Map">
select<includerefid="table_columns"/>,
DATE(start_time)startTimeExport,
(CASEstatusWHEN1THEN"报名中"WHEN2THEN"进行中"WHEN0THEN"已完成"ELSEstatusEND)statusChinese,
(CASEpostion_typeWHEN1THEN"独立办公室"WHEN2THEN"开放工位"ELSEpostion_typeEND)postionTypeName,
(CASEmode_paymentWHEN1THEN"工位/日租"WHEN2THEN"工位/月租"WHEN3THEN"面积/天"ELSEmode_paymentEND)modePaymentName
fromt_company
<includerefid="whereSql"/>
</select>
推荐阅读
-
PHP将Excel导入数据库及数据库数据导出至Excel的方法,excel数据导出_PHP教程
-
使用java打印所有的水仙花数
-
弹窗时解决错误java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
-
IDEA中add framework support时缺少Spring,Java EE等框架支持
-
java设计模式(实战)-责任链模式
-
Java之HashMap源码分析(第五篇:访问元素)
-
详解Java匿名内部类
-
项目js java 实现自动复制粘贴 亲测有效
-
JAVA Web.xml加载顺序过程详解
-
java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to