From e358db4c8529df3fc44df9eb7c6b289ddab3cc2e Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Fri, 17 Sep 2021 19:17:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + .../easyexcel/test/temp/Lock2Test.java | 2 +- .../easyexcel/test/temp/poi/PoiTest.java | 25 ++++++++----------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 85969631..3f29ad91 100644 --- a/pom.xml +++ b/pom.xml @@ -172,6 +172,7 @@ com/alibaba/excel/metadata/format/DataFormatter.java com/alibaba/excel/metadata/format/ExcelGeneralNumberFormat.java com/alibaba/excel/metadata/csv/CsvDataFormat.java + com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java b/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java index e2f5d0ec..3082362a 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java @@ -36,7 +36,7 @@ public class Lock2Test { // File file = TestFileUtil.readUserHomeFile("test/test6.xls"); File file = new File("/Users/zhuangjiaju/IdeaProjects/easyexcel/src/test/resources/converter/converter07.xlsx"); - List list = EasyExcel.read("/Users/zhuangjiaju/Downloads/1 (2).xlsx").sheet(0).doReadSync(); + List list = EasyExcel.read("/Users/zhuangjiaju/test/test3.xlsx").sheet(0).headRowNumber(0).doReadSync(); LOGGER.info("数据:{}", list.size()); for (Object data : list) { LOGGER.info("返回数据:{}", CollectionUtils.size(data)); diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiTest.java index f7778338..349e02c9 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiTest.java @@ -3,11 +3,13 @@ package com.alibaba.easyexcel.test.temp.poi; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.util.Date; + +import com.alibaba.easyexcel.test.util.TestFileUtil; +import com.alibaba.excel.util.FileUtils; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellCopyPolicy; -import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.streaming.SXSSFRow; @@ -21,11 +23,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.alibaba.easyexcel.test.util.TestFileUtil; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.ExcelReader; -import com.alibaba.excel.util.FileUtils; - /** * 测试poi * @@ -37,27 +34,25 @@ public class PoiTest { @Test public void lastRowNum() throws IOException { - String file = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx"; + String file = "/Users/zhuangjiaju/test/test3.xlsx"; SXSSFWorkbook xssfWorkbook = new SXSSFWorkbook(new XSSFWorkbook(file)); SXSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); SXSSFRow row = xssfSheet.getRow(0); - LOGGER.info("第一行数据:{}", row); - xssfSheet.createRow(20); - LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); + Date date = row.getCell(1).getDateCellValue(); + } @Test public void lastRowNumXSSF() throws IOException { - String file = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx"; + String file = "/Users/zhuangjiaju/test/test3.xlsx"; XSSFWorkbook xssfWorkbook = new XSSFWorkbook(file); LOGGER.info("一共:{}个sheet", xssfWorkbook.getNumberOfSheets()); XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); XSSFRow row = xssfSheet.getRow(0); - LOGGER.info("第一行数据:{}", row); - xssfSheet.createRow(20); - LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); + Date date = row.getCell(1).getDateCellValue(); + LOGGER.info("date{}",date); } @Test