forked from fanruan/easyexcel
Browse Source
# Conflicts: # src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.javadeveloping
Jiaju Zhuang
3 years ago
4 changed files with 83 additions and 1 deletions
@ -0,0 +1,35 @@
|
||||
package com.alibaba.easyexcel.test.demo.Test1702; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
||||
import java.util.Date; |
||||
|
||||
public class Date1702 { |
||||
@ExcelProperty(index = 0) |
||||
private String str; |
||||
@ExcelProperty(index = 1) |
||||
private Date date; |
||||
@ExcelProperty(index = 2) |
||||
private double r; |
||||
public void setStr(String str) { |
||||
this.str = str; |
||||
} |
||||
public void setDate(Date date) { |
||||
this.date = date; |
||||
} |
||||
public void setR(double r) { |
||||
this.r = r; |
||||
} |
||||
|
||||
public String getStr() { |
||||
return str; |
||||
} |
||||
|
||||
public Date getDate(){ |
||||
return date; |
||||
} |
||||
public double getR(){ |
||||
return r; |
||||
} |
||||
} |
||||
|
Binary file not shown.
@ -0,0 +1,47 @@
|
||||
package com.alibaba.easyexcel.test.demo.Test1702; |
||||
|
||||
import com.alibaba.easyexcel.test.util.TestFileUtil; |
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.excel.EasyExcelFactory; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.FileNotFoundException; |
||||
import java.io.InputStream; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
public class Issue1702 { |
||||
@Test |
||||
public void test1702() throws FileNotFoundException { |
||||
|
||||
// String fileName = TestFileUtil.getPath() + "TestIssue" + File.separator + "Date1702.xlsx";
|
||||
String fileName = "src/test/java/com/alibaba/easyexcel/test/demo/Test1702/Date1702.xlsx"; |
||||
EasyExcel.write(fileName).head(head()).sheet("模板").doWrite(dataList()); |
||||
InputStream inputStream = new FileInputStream(fileName); |
||||
List<Date1702> list = EasyExcelFactory.read(inputStream).head(Date1702.class).sheet(0).doReadSync(); |
||||
Assert.assertEquals("字符串",list.get(0).getStr()); |
||||
} |
||||
|
||||
|
||||
private List<List<String>> head() { |
||||
List<List<String>> list = new ArrayList<List<String>>(); |
||||
List<String> head0 = new ArrayList<String>(); |
||||
head0.add("表头"); |
||||
list.add(head0); |
||||
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; |
||||
} |
||||
} |
Loading…
Reference in new issue