首页 > 其他 > 详细

Excel文件下载

时间:2020-02-22 16:32:12      阅读:84      评论:0      收藏:0      [点我收藏+]

 

//controller
@GetMapping("/export")
public ResponseEntity<byte[]> exportDate(){
List<Employee> list= (List<Employee>) employeeService.getEmployeeByPage(null,null,null).getData();

return POIUtils.employee2Excel(list);
}
 
   

                

package com.song.vhr.controller.Emp;

import com.song.vhr.model.*;
import com.song.vhr.service.*;
import com.song.vhr.utils.POIUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author song
* @data 2020/2/21
*/
@RestController
@RequestMapping("/emp/basic")
public class EmpBasicController {

@Autowired
EmployeeService employeeService;
@Autowired
NationService nationService;
@Autowired
PoliticsstatusService politicsstatusService;
@Autowired
PositionService positionService;

@Autowired
JobLevelService jobLevelService;
@GetMapping("/")
public RespPageBean getEmployeeByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10")Integer size,String keywords){
return employeeService.getEmployeeByPage(page,size,keywords);
}

@PostMapping("/")
public RespBean addEmp(@RequestBody Employee employee){
if(employeeService.addEmp(employee)==1){
return RespBean.ADD_SUCCESS;
}
return RespBean.ADD_ERROR;
}

@GetMapping("/nations")
public List<Nation> getAllNations(){
return nationService.getAllNations();
}
@GetMapping("/politicsstatus")
public List<Politicsstatus> getAllPoliticsstatus(){
return politicsstatusService.getAllPoliticsstatus();
}

@GetMapping("/jobLevels")
public List<JobLevel> getAllJobLevel(){
return jobLevelService.getAllJobLevels();
}
@GetMapping("/position")
public List<Position> getAllPosition(){
return positionService.getAllPositions();
}

@GetMapping("/maxWordID")
public RespBean maxWordID(){

return RespBean.ok("",String.format("%08d",employeeService.maxWordID()+1));
}

@DeleteMapping("/{id}")
public RespBean deleteEmp(@PathVariable Integer id){
if(employeeService.deleteEmp(id)==1){
return RespBean.DELETE_SUCCESS;
}
return RespBean.DELETE_ERROR;
}
@PutMapping("/")
public RespBean updateEmp(@RequestBody Employee employee){
if(employeeService.updateEmp(employee)==1){
return RespBean.UPDATE_SUCCESS;
}
return RespBean.UPDATE_ERROR;
}

@GetMapping("/export")
public ResponseEntity<byte[]> exportDate(){
List<Employee> list= (List<Employee>) employeeService.getEmployeeByPage(null,null,null).getData();

return POIUtils.employee2Excel(list);
}

}
 
   
exportData(){
window.open("/emp/basic/export","_parent")
},
 
   

 

Excel文件下载

原文:https://www.cnblogs.com/sgs98/p/12345569.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!