mirror of https://github.com/alibaba/easyexcel
焦松
4 years ago
4 changed files with 101 additions and 2 deletions
@ -0,0 +1,33 @@
|
||||
package com.alibaba.easyexcel.test.temp.bug; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author jiaosong |
||||
* @desc |
||||
* @date 2021/4/6 |
||||
*/ |
||||
@Data |
||||
public class DataType { |
||||
/** |
||||
* 任务id |
||||
*/ |
||||
@ExcelProperty("任务ID") |
||||
private Integer id; |
||||
|
||||
@ExcelProperty("多余字段1") |
||||
private String firstSurplus; |
||||
|
||||
@ExcelProperty("多余字段2") |
||||
private String secSurplus; |
||||
|
||||
@ExcelProperty("多余字段3") |
||||
private String thirdSurplus; |
||||
|
||||
@ExcelProperty(value = "备注1") |
||||
private String firstRemark; |
||||
|
||||
@ExcelProperty(value = "备注2") |
||||
private String secRemark; |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.alibaba.easyexcel.test.temp.bug; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.excel.ExcelWriter; |
||||
import com.alibaba.excel.write.metadata.WriteSheet; |
||||
|
||||
import java.io.FileNotFoundException; |
||||
import java.io.FileOutputStream; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author jiaosong |
||||
* @desc |
||||
* @date 2020/4/6 |
||||
*/ |
||||
public class ExcelCreat { |
||||
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException { |
||||
List<DataType> data = getData(); |
||||
ExcelWriter excelWriter = null; |
||||
excelWriter = EasyExcel.write(new FileOutputStream("all.xlsx")).build(); |
||||
WriteSheet writeSheet = EasyExcel.writerSheet(1, "test") |
||||
.head(HeadType.class) |
||||
.build(); |
||||
excelWriter.write(data, writeSheet); |
||||
excelWriter.finish(); |
||||
} |
||||
|
||||
private static List<DataType> getData() { |
||||
DataType vo = new DataType(); |
||||
vo.setId(738); |
||||
vo.setFirstRemark("1222"); |
||||
vo.setSecRemark("22222"); |
||||
return Collections.singletonList(vo); |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.alibaba.easyexcel.test.temp.bug; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author jiaosong |
||||
* @desc |
||||
* @date 2021/4/6 |
||||
*/ |
||||
@Data |
||||
public class HeadType { |
||||
|
||||
|
||||
/** |
||||
* 任务id |
||||
*/ |
||||
@ExcelProperty("任务ID") |
||||
private Integer id; |
||||
|
||||
|
||||
@ExcelProperty(value = "备注1") |
||||
private String firstRemark; |
||||
|
||||
@ExcelProperty(value = "备注2") |
||||
private String secRemark; |
||||
|
||||
} |
Loading…
Reference in new issue