导入excel文件信息

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;
    }

  

posted on 2020-12-25 10:02  james-roger  阅读(159)  评论(0编辑  收藏  举报