导出文件:使用Hutool导出数据为Excel文件

  • @Author Heartsuit

  • @Date 2021-08-09

*/

@RestController

@RequestMapping(“employee”)

public class EmployeeController {

private final EmployeeService employeeService;

public EmployeeController(EmployeeService employeeService) {

this.employeeService = employeeService;

}

/**

  • 导出全量数据,实际一般为条件检索后导出

  • @param response

  • @throws IOException

*/

@GetMapping(“export-xls”)

public void exportExcel(HttpServletResponse response) throws IOException, ClassNotFoundException {

ExcelWriter writer = ExcelUtil.getWriter();

List employees = employeeService.findAll();

List> rows = employees.stream().map(item -> {

Map maps = new HashMap<>();

你可能感兴趣的:(程序员,excel,windows)