easypoi
import cn.afterturn.easypoi.excel.annotation.Excel; import lombok.Data; @Data public class MaterielExcel implements java.io.Serializable{ @Excel(name = "SNAME") private String startName; @Excel(name = "SX") private Double startX; @Excel(name = "SY") private Double startY; @Excel(name = "ENAME") private String endName; @Excel(name = "EX") private Double endX; @Excel(name = "EY") private Double endY; @Excel(name = "MATERIAL") private String materiel; @Excel(name = "AMOUNT") private Double amount; @Excel(name = "SRID") private String srid; }
@PostMapping(value = "/upload") public List<String> saveMateriel(@PathVariable("projectId") String projectId, @RequestParam("file") MultipartFile file) throws Exception { ImportParams params = new ImportParams(); // params.setTitleRows(1); params.setHeadRows(1); List<MaterielExcel> list = ExcelImportUtil.importExcel(file.getInputStream(), MaterielExcel.class, params); return odService.save(list, projectId); // return Commons.EMPTY; }