直接保存到本地磁盘
public static void main(String[] args) throws IOException {
String excelFilePath = "F:/ftproot/METAMSC/20231011/fskbook.xlsx";
String imagePath = "D:/temp";
try {
FileInputStream fis = new FileInputStream(new File(excelFilePath));
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFDrawing drawings = sheet.getDrawingPatriarch();
List<XSSFShape> shapes = drawings.getShapes();
int i=0;
for (XSSFShape shape : shapes) {
if (shape instanceof XSSFPicture) {
++i;
if (i ==4){
continue;
}
XSSFPicture picture = (XSSFPicture) shape;
PictureData pictureData = picture.getPictureData();
byte[] data = pictureData.getData();
String imageFileName = UUID.randomUUID().toString