此demo仅做参考(根据id导出ecxel文件):
Controller层:
@GetMapping("/export")
public void export(String bjIds, HttpServletResponse response) throws IOException {
//获取id
List<Long> bjIdList = Func.toLongList(bjIds);
//获取数据 存到list sql自己写需要的
List<StuExportExcel> exportExcels = studentService.getAllByBjs(bjIdList);
//拿到第一个bjid
Long bjId = bjIdList.get(0);
//通过id获取表头名字
String fileName = XgCache.getBjName(bjId);
//2 获取Excel模版
Attach attach = attachService.lambdaQuery().eq(Attach::getOriginalName, "stu_temp.xlsx").one();
if (attach == null) {
throw new ServiceException("模版不存在");
}
//获取附件地址 stu_temp.xlsx(地址已存入附件管理)
String attachLink = attach.getLink();
//获取url<