导入execl文件
public void test() throws Exception {
File file = new File("D:/易耗品订货日(1)(1).xlsx");
if (!file.exists()){
throw new Exception("文件不存在!");
}
InputStream in = new FileInputStream(file);
XSSFWorkbook sheets = new XSSFWorkbook(in);
XSSFSheet sheetAt = sheets.getSheetAt(0);
XSSFRow titleRow = sheetAt.getRow(0);
List<Map> ls =new ArrayList<>();
for (int i = 1; i < sheetAt.getPhysicalNumberOfRows(); i++) {
XSSFRow row = sheetAt.getRow(i);
Map map = new HashMap();
for (int index = 0; index < row.getPhysicalNumberOfCells(); index++) {
XSSFCell titleCell = titleRow.getCell(index);
XSSFCell cell = row.getCell(index);
cell.setCellType(Cell.CELL_TYPE_STRING);
if (cell.getStringCellValue().equals("")) {
continue;
}
map.put(index,cell);
}
ls.add(map);
}
}