From c30a89d4f6141ff6c369f4dc4b0f4e8b7a1a1863 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Thu, 16 Sep 2021 15:59:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E=E8=A1=8C?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/AbstractExcelWriteExecutor.java | 4 +++ .../easyexcel/test/temp/Lock2Test.java | 30 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java b/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java index ed2806de..5cd0cda2 100644 --- a/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java +++ b/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java @@ -75,6 +75,10 @@ public abstract class AbstractExcelWriteExecutor implements ExcelWriteExecutor { // Fill in style information fillStyle(cell, cellData.getWriteCellStyle()); + // Fill index + cellData.setRowIndex(cell.getRowIndex()); + cellData.setColumnIndex(cell.getColumnIndex()); + if (cellData.getType() == null) { cellData.setType(CellDataTypeEnum.EMPTY); } 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 cc81f194..e722344d 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java @@ -82,6 +82,36 @@ public class Lock2Test { .doWrite(data()); } + @Test + public void simpleWrite() { + String fileName = TestFileUtil.getPath() + System.currentTimeMillis() + ".xlsx"; + System.out.println(fileName); + EasyExcel.write(fileName).head(head()).sheet("模板").doWrite(dataList()); + } + + private List> head() { + List> list = new ArrayList>(); + List head0 = new ArrayList(); + head0.add("表头"); + + list.add(head0); + List head1 = new ArrayList(); + head1.add("表头2"); + + list.add(head1); + return list; + } + + private List> dataList() { + List> list = new ArrayList>(); + List data = new ArrayList(); + data.add("字符串"); + data.add(new Date()); + //data.add(0.56); + list.add(data); + return list; + } + private List data() { List list = new ArrayList(); for (int i = 0; i < 10; i++) {