hutool 工具 ExcelWriter 导出下拉数据使用
具体代码如下
//获取下拉数据
String[] splitV0164 = DictUtils.getStrArr(v0164);
//获取编码值
String[] strArrKeyV0164 = DictUtils.getStrArrKey(v0164);
//设置导航栏下拉提示
ExcelUtils.setDownBox(sheet, splitV0164, 0, 0,2,2);
//设置选择数据
ExcelUtils.setDownBox(sheet, strArrKeyV0164, 1, 1000,2,2);
具体代码:
//导出数据 List<StorageStorehouseDto> routineList = null; // 写出到流 ExcelWriter excelWriter = ExcelUtil.getWriter(true); // 设置别名 excelWriter.addHeaderAlias("storeNum", "编号"); try { if(null!=ids&&ids.size()==1&&ids.get(0)==0){ routineList=new ArrayList<>(); StorageStorehouseDto storageStorehouseDto=new StorageStorehouseDto(); storageStorehouseDto.setId(0L); routineList.add(storageStorehouseDto); Sheet sheet = excelWriter.getSheet(); Response<Object> v0164 = vcsParameterService.getDictinfo("V0164"); String[] splitV0164 = DictUtils.getStrArr(v0164); String[] strArrKeyV0164 = DictUtils.getStrArrKey(v0164); //设置导航栏下拉提示 ExcelUtils.setDownBox(sheet, splitV0164, 0, 0,2,2); //设置选择数据 ExcelUtils.setDownBox(sheet, strArrKeyV0164, 1, 1000,2,2); } String fileName = "信息" + IdUtil.objectId() + ".xlsx"; OutputStream outputStream = response.getOutputStream(); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); response.setHeader("Content-Disposition","attachment;filename=" + FileUtils.setFileDownloadHeader(request, fileName)); // 只显示设置了别名的 excelWriter.setOnlyAlias(true); // 写入excel excelWriter.write(routineList, true); // 写出 excelWriter.flush(outputStream); } catch (Exception e) { log.error("业务导出EXCEL", e); } finally { // 释放内存 excelWriter.close(); } }
我是个双鱼座的小王子,沉浸在自己的代码世界里,去探索这未知的世界,希望遇到更多的小伙伴一起前行!

浙公网安备 33010602011771号