欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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>
相关标签: 导出