从EXcel文件中读取数据导入库

  
  import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

//友情提示这里不要导错包

public void insertexcel() throws IOException, BiffException { File file = new File("C:/Users/1/Desktop/888.xls");
      //从桌面读取文件 Workbook book
= Workbook.getWorkbook(file); Sheet sheet = book.getSheet(0); for (int i = 1; i < sheet.getRows(); i++) { MwsFeePreview mwsFeePreview=new MwsFeePreview(); mwsFeePreview.setSellerId("1"); for (int j = 0; j < sheet.getColumns(); j++) { Cell cell = sheet.getCell(j, i); //单元格子 j是列 ,i是行 //实体类封装 XXXMapper.insert(mwsFeePreview);

      //入库操作,建议使用mybatis plus封装好的insert直接用实体类当参数即可,字段很多时会比较方便。

 

posted @ 2021-02-04 14:49  cire  阅读(92)  评论(0)    收藏  举报
/* 看板娘 */