Browse Source

修改返回行列

pull/2077/head
Jiaju Zhuang 3 years ago
parent
commit
c30a89d4f6
  1. 4
      src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java
  2. 30
      src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java

4
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);
}

30
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<List<String>> head() {
List<List<String>> list = new ArrayList<List<String>>();
List<String> head0 = new ArrayList<String>();
head0.add("表头");
list.add(head0);
List<String> head1 = new ArrayList<String>();
head1.add("表头2");
list.add(head1);
return list;
}
private List<List<Object>> dataList() {
List<List<Object>> list = new ArrayList<List<Object>>();
List<Object> data = new ArrayList<Object>();
data.add("字符串");
data.add(new Date());
//data.add(0.56);
list.add(data);
return list;
}
private List<DemoData> data() {
List<DemoData> list = new ArrayList<DemoData>();
for (int i = 0; i < 10; i++) {

Loading…
Cancel
Save