From 7fac3bf318b7e47f82417aee1742ebec0f375a40 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Wed, 8 Feb 2023 17:28:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=A7=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=A1=88=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/temp/write/TempWriteTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/write/TempWriteTest.java b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/write/TempWriteTest.java index b084ed04..a8603f12 100644 --- a/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/write/TempWriteTest.java +++ b/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/write/TempWriteTest.java @@ -132,4 +132,51 @@ public class TempWriteTest { fileOutputStream.flush(); workbook.close(); } + + @Test + public void tep() throws Exception { + String file = "/Users/zhuangjiaju/test/imagetest" + System.currentTimeMillis() + ".xlsx"; + SXSSFWorkbook workbook = new SXSSFWorkbook(); + SXSSFSheet sheet = workbook.createSheet("测试"); + CreationHelper helper = workbook.getCreationHelper(); + SXSSFDrawing sxssfDrawin = sheet.createDrawingPatriarch(); + + byte[] imagebyte = FileUtils.readFileToByteArray(new File("/Users/zhuangjiaju/Documents/demo.jpg")); + + for (int i = 0; i < 1 * 10000; i++) { + SXSSFRow row = sheet.createRow(i); + SXSSFCell cell = row.createCell(0); + cell.setCellValue(i); + int pictureIdx = workbook.addPicture(imagebyte, Workbook.PICTURE_TYPE_JPEG); + ClientAnchor anchor = helper.createClientAnchor(); + anchor.setCol1(0); + anchor.setRow1(i); + // 插入图片 + Picture pict = sxssfDrawin.createPicture(anchor, pictureIdx); + pict.resize(); + log.info("新增行:{}", i); + } + FileOutputStream fileOutputStream = new FileOutputStream(file); + workbook.write(fileOutputStream); + fileOutputStream.flush(); + workbook.close(); + } + + @Test + public void large() throws Exception { + String file = "/Users/zhuangjiaju/test/imagetest" + System.currentTimeMillis() + ".xlsx"; + SXSSFWorkbook workbook = new SXSSFWorkbook(new XSSFWorkbook( + new File("/Users/zhuangjiaju/IdeaProjects/easyexcel/easyexcel-test/src/test/resources/large/large07.xlsx"))); + SXSSFSheet sheet = workbook.createSheet("测试"); + + SXSSFRow row = sheet.createRow(500000); + SXSSFCell cell = row.createCell(0); + cell.setCellValue("test"); + + FileOutputStream fileOutputStream = new FileOutputStream(file); + workbook.write(fileOutputStream); + fileOutputStream.flush(); + workbook.close(); + + } }