PS一次性导出多倍图@1x、@2x、@3x

1、文件 — 导出 — 导出为

还可以在图层栏右击在下拉菜单中选择导出为

 

2、在导出为界面选择需要导出的数据;可以选择几倍图,还有图片的格式、大小等。

 

 

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在 easyexcel2.x 版本中,可以通过实现 `WriteHandler` 接口来实现导出多张片。 具体步骤如下: 1. 创建一个实现了 `WriteHandler` 接口的类,例如 `ImageHandler`。在该类中,需要实现 `cell` 方法和 `afterSheetCreate` 方法。 2. 在 `cell` 方法中,判断当前单元格是否是片类型,如果是片类型,则将导出到指定目录,并记录片路径。 3. 在 `afterSheetCreate` 方法中,将记录的片路径插入到 Excel 中。 以下是示例代码: ```java public class ImageHandler implements WriteHandler { private Map<String, String> imagePathMap = new HashMap<>(); private String imageDir = "D:/images/"; @Override public void cell(CellWriteHandlerContext context) { CellData cellData = context.getCellData(); if (cellData instanceof ImageData) { ImageData imageData = (ImageData) cellData; String imageName = imageData.getImageName(); String imagePath = imageDir + imageName; try { File imageFile = new File(imagePath); if (!imageFile.exists()) { FileOutputStream fos = new FileOutputStream(imageFile); fos.write(imageData.getData()); fos.close(); } imagePathMap.put(imageName, imagePath); } catch (Exception e) { e.printStackTrace(); } } } @Override public void afterSheetCreate(AfterSheetWriteHandlerContext context) { Sheet sheet = context.getSheet(); Drawing<?> drawing = sheet.createDrawingPatriarch(); imagePathMap.forEach((imageName, imagePath) -> { try { // 设置片位置和大小 int pictureIdx = sheet.getWorkbook().addPicture(new FileInputStream(imagePath), Workbook.PICTURE_TYPE_PNG); CreationHelper helper = sheet.getWorkbook().getCreationHelper(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setCol1(0); anchor.setRow1(0); anchor.setCol2(5); anchor.setRow2(5); Picture pict = drawing.createPicture(anchor, pictureIdx); pict.resize(); } catch (Exception e) { e.printStackTrace(); } }); } } ``` 然后在导出 Excel 的代码中,通过 `EasyExcel.write()` 方法的 `registerWriteHandler()` 方法将 `ImageHandler` 注册到写操作中,即可实现导出多张片。 ```java EasyExcel.write("D:/test.xlsx") .registerWriteHandler(new ImageHandler()) .sheet("Sheet1") .doWrite(data); ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值