excel中的图片保存

重命名为zip(推荐)

1、excel文件后缀重命名为zip
2、解压到当前文件夹
3、搜索*.png即可看到所有图片 (多张图片也一样)

另存为网页

文件 | 另存为 | html网页 ,然后打开这个文件,右键图片,另存为即可。

缺点: 如果是多张图片,需要一张一张另存。

复制到剪切板,或者powerpoint(或者微信,钉钉窗口也可)

复制,黏贴到剪切板,或者powerpoint ,再保存即可。

你可以使用 Apache POI 库来读取 Excel 文件并获取图片,然后使用 Java 的文件操作 API 将图片保存到本地。 以下是一个示例代码,可以帮助你实现这个功能: ```java import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Drawing; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class ExcelImageExtractor { public static void extractImagesFromExcel(String filePath, String savePath) { try { Workbook workbook = new XSSFWorkbook(new File(filePath)); int numberOfSheets = workbook.getNumberOfSheets(); for (int i = 0; i < numberOfSheets; i++) { Drawing<?> drawing = workbook.getSheetAt(i).getDrawingPatriarch(); if (drawing != null) { drawing.forEach(shape -> { if (shape.getImageData() != null) { try { InputStream imageStream = shape.getImageData().getData(); String imageExtension = shape.getPictureData().suggestFileExtension(); File outputFile = new File(savePath + File.separator + "image" + i + "." + imageExtension); FileOutputStream outputStream = new FileOutputStream(outputFile); byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = imageStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytesRead); } outputStream.close(); imageStream.close(); } catch (IOException e) { e.printStackTrace(); } } }); } } workbook.close(); } catch (IOException | InvalidFormatException e) { e.printStackTrace(); } } } ``` 你可以调用 `extractImagesFromExcel` 方法,将 Excel 文件的路径和保存图片的路径作为参数传入。代码会自动读取 Excel 图片,并将它们保存到本地。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值