av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

SpringBoot+easypoi實(shí)現(xiàn)數(shù)據(jù)的Excel導(dǎo)出

瀏覽:120日期:2022-06-15 18:25:35

本文實(shí)例為大家分享了SpringBoot+easypoi實(shí)現(xiàn)數(shù)據(jù)的Excel導(dǎo)出的具體代碼,供大家參考,具體內(nèi)容如下

maven

<dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-spring-boot-starter</artifactId> <version>4.1.0</version></dependency>

Controller層

// 接口不需要返回值@RequestMapping(value = '/export-activity-data')public void exportActivityData(@RequestParam String activityType, @RequestParam String activityState, @RequestParam String queryValue, @RequestParam String levelValue, @RequestParam String startTime, @RequestParam String endTime, HttpServletResponse response) {try { manageService.exportActivityData(TFActivityQueryParam.builder() .activityState(activityState) .activityType(activityType) .queryValue(queryValue) .levelValue(levelValue) .startTime(''.equals(endTime) ? null : new Date(DateTime.parse(startTime).getMillis())) .endTime(''.equals(endTime) ? null : new Date(DateTime.parse(endTime).getMillis())).build(), response);} catch (IOException e) { log.info( '導(dǎo)出失敗', e);} }

service層

public void exportActivityData(TFActivityQueryParam param, HttpServletResponse response) throws IOException {response.setCharacterEncoding('UTF-8');response.setHeader('content-Type', 'application/vnd.ms-excel');response.setHeader('Content-Disposition','attachment;filename=' + URLEncoder.encode('活動(dòng)綜合數(shù)據(jù).xls', 'UTF-8'));val out = response.getOutputStream();List<TFActivityQueryResult> tfActivityList = getTFActivityList(param);List<TFActivityQueryResultExportDto> exportDtoList = new ArrayList<>();tfActivityList.forEach(activity -> { TFActivityQueryResultExportDto convert = TFActivityQueryResultExportDto.convert(activity); if (activity.getLevelType().equals('0')) {convert.setAffiliation('云南省'); } else {EparchyCode eparchyCode = getEparchyCodeList().stream().filter(code -> code.getEparchyCode().equals(activity.getEparchyCode())).collect(Collectors.toList()).get(0);convert.setAffiliation(eparchyCode.getEparchyShortName()); } exportDtoList.add(convert);});Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams('活動(dòng)綜合數(shù)據(jù)', '活動(dòng)'), TFActivityQueryResultExportDto.class, exportDtoList);log.info('workbook: {}', workbook);workbook.write(out);out.close(); }

數(shù)據(jù)bean

public class TFActivityQueryResultExportDto { @Excel(name = '活動(dòng)編碼', width = 20) private String activityCode; @Excel(name = '活動(dòng)名稱', width = 20) private String activityName; @Excel(name = '活動(dòng)標(biāo)題', width = 20) private String activityTitle; @Excel(name = '歸屬', width = 20) private String affiliation; @Excel(name = '活動(dòng)類型', width = 20) private String activityType; @Excel(name = '活動(dòng)時(shí)間', width = 30) private String activityTime; @Excel(name = '活動(dòng)狀態(tài)', width = 20) private String activityState; @Excel(name = '備注', width = 30) private String remark; @Excel(name = '創(chuàng)建時(shí)間', width = 30) private String timeCreate; @Excel(name = '最新操作人', width = 30) private String operatorName; @Excel(name = '更新時(shí)間', width = 30) private String timeUpdate;}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: excel
相關(guān)文章:
主站蜘蛛池模板: 草久网| 欧美日韩综合 | 中文字幕亚洲视频 | 日本成人中文字幕在线观看 | 97视频在线观看免费 | 亚洲成人自拍 | 久久久精品日本 | 欧美在线一区二区视频 | 精品中文在线 | 91免费电影 | 久久久久国产一区二区 | 精品1区2区 | 999久久久久久久久 国产欧美在线观看 | 91久久国产综合久久 | 国产午夜视频 | 伊人网在线看 | 国产免费视频 | www.亚洲精品 | 欧洲一级毛片 | 99精品视频免费在线观看 | 精品乱码一区二区三四区视频 | 国产精品99久久久久久久久 | 天堂在线免费视频 | 五月花丁香婷婷 | 91精品在线看 | av久久 | 国产精品一区二区在线免费观看 | 亚洲国产网站 | 精品毛片在线观看 | 国产免费一区二区 | 在线欧美一区 | 午夜影院在线观看免费 | 欧美日韩亚洲在线 | 国产在线观看一区二区三区 | 一级在线观看 | 国精久久 | av网站在线播放 | 久草免费在线视频 | 日韩在线不卡 | 一区二区亚洲 | 99re免费 |