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++) {