List<SaleOrderExportDTO> list = TransferUtil.transferList(queryList, SaleOrderExportDTO.class);
//导出
PoiUtil<SaleOrderExportDTO> poiUtil = new PoiUtil<SaleOrderExportDTO>(SaleOrderExportDTO.class);
HSSFWorkbook workbook = poiUtil.exportExcel(list);
String fileName = "订单发货数据导出报表";
OutputStream output = null;
OutputStream out = null;
try {
response.setHeader("Content-disposition","attachment;filename="+ URLEncoder.encode(fileName,"UTF-8")+".xls;filename*=UTF-8''"+URLEncoder.encode(fileName,"UTF-8")+".xls");
response.setContentType("application/octet-stream;charset=UTF-8");
output = response.getOutputStream();
out = new ByteArrayOutputStream();
workbook.write(output);
out.flush();
out.close();
} catch (IOException e) {
//
} finally {
if (output != null) {
try {
output.close();
} catch (IOException e) {
//
}
}
}
转载于:https://www.cnblogs.com/YuyuanNo1/p/8440958.html