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(); } }
我是个双鱼座的小王子,沉浸在自己的代码世界里,去探索这未知的世界,希望遇到更多的小伙伴一起前行!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现
2021-01-13 Postgresql常用函数整理