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>