@PostMapping(value = "/importExcel2/v1", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public void importExcel2(@RequestPart("file") MultipartFile file) { int i = 0; try { HSSFWorkbook tempWorkBook = new HSSFWorkbook(file.getInputStream()); // 获取模板sheet页 HSSFSheet sheet = tempWorkBook.getSheetAt(0); List<HSSFShape> children = sheet.getDrawingPatriarch().getChildren(); for (HSSFShape shape : children) { if (shape instanceof HSSFPicture) { HSSFPicture picture = (HSSFPicture) shape; HSSFClientAnchor cAnchor = picture.getClientAnchor(); HSSFPictureData pdata = picture.getPictureData(); //获取图片行号列号 String key = cAnchor.getRow1() + "-" + cAnchor.getCol1(); String mimeType = pdata.getMimeType(); //文件后缀 String s = pdata.suggestFileExtension(); byte[] data = pdata.getData(); FileOutputStream out = new FileOutputStream(System.currentTimeMillis() + "无题." + s); out.write(data); out.close(); } } } catch (Exception e) { e.printStackTrace(); } }