@PostMapping("/waterTest/importData")
public void importData(MultipartFile file, HttpServletRequest req) throws IOException {
InputStream inputStream = file.getInputStream();
try {
//获取到的list集合
List> list = getListByExcel(inputStream);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @Description:获取IO流中的数据,组装成List>对象
* @param in,fileName
* @return
* @throws IOException
*/
public static List> getListByExcel(InputStream in) throws Exception{
List> list = null;
//创建Excel工作薄
Workbook work = new HSSFWorkbook(in);
if(null == work){
throw new Exception("创建Excel工作薄为空!");
}
Sheet sheet = null; //页数
Row row = null; //行数
Cell cell = null; //列数
list = new ArrayList>();
//遍历Excel中所有的sheet
sheet = work.getSheetAt(0);
//遍历当前sheet中的所有行
for (int j = sheet.getFirstRowNum(); j <= sheet.getLastRowNum(); j++) {
row = sheet.getRow(j);
if(row==null||row.getFirstCellNum()==j){continue;}
//遍历所有的列
List