forked from github/easyexcel
zhuangjiaju
5 years ago
27 changed files with 259 additions and 155 deletions
@ -0,0 +1,45 @@
|
||||
package com.alibaba.easyexcel.test.core.converter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author zhuangjiaju |
||||
*/ |
||||
@Data |
||||
public class ReadAllConverterData { |
||||
private BigDecimal bigDecimalBoolean; |
||||
private BigDecimal bigDecimalNumber; |
||||
private BigDecimal bigDecimalString; |
||||
private Boolean booleanBoolean; |
||||
private Boolean booleanNumber; |
||||
private Boolean booleanString; |
||||
private Byte byteBoolean; |
||||
private Byte byteNumber; |
||||
private Byte byteString; |
||||
private Date dateNumber; |
||||
private Date dateString; |
||||
private Double doubleBoolean; |
||||
private Double doubleNumber; |
||||
private Double doubleString; |
||||
private Float floatBoolean; |
||||
private Float floatNumber; |
||||
private Float floatString; |
||||
private Integer integerBoolean; |
||||
private Integer integerNumber; |
||||
private Integer integerString; |
||||
private Long longBoolean; |
||||
private Long longNumber; |
||||
private Long longString; |
||||
private Short shortBoolean; |
||||
private Short shortNumber; |
||||
private Short shortString; |
||||
private String StringBoolean; |
||||
private String StringNumber; |
||||
private String StringString; |
||||
private String StringError; |
||||
private String StringFormulaNumber; |
||||
private String StringFormulaString; |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.alibaba.easyexcel.test.core.converter; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.junit.Assert; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import com.alibaba.excel.context.AnalysisContext; |
||||
import com.alibaba.excel.event.AnalysisEventListener; |
||||
import com.alibaba.fastjson.JSON; |
||||
|
||||
/** |
||||
* @author zhuangjiaju |
||||
*/ |
||||
public class ReadAllConverterDataListener extends AnalysisEventListener<ReadAllConverterData> { |
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ReadAllConverterDataListener.class); |
||||
List<ReadAllConverterData> list = new ArrayList<ReadAllConverterData>(); |
||||
|
||||
@Override |
||||
public void invoke(ReadAllConverterData data, AnalysisContext context) { |
||||
list.add(data); |
||||
} |
||||
|
||||
@Override |
||||
public void doAfterAllAnalysed(AnalysisContext context) { |
||||
Assert.assertEquals(list.size(), 1); |
||||
ReadAllConverterData data = list.get(0); |
||||
// try {
|
||||
// Assert.assertEquals(data.getDate(), DateUtils.parseDate("2020-01-01 01:01:01"));
|
||||
// } catch (ParseException e) {
|
||||
// throw new ExcelCommonException("Test Exception", e);
|
||||
// }
|
||||
// Assert.assertEquals(data.getBooleanData(), Boolean.TRUE);
|
||||
// Assert.assertEquals(data.getBigDecimal().doubleValue(), BigDecimal.ONE.doubleValue(), 0.0);
|
||||
// Assert.assertEquals((long)data.getLongData(), 1L);
|
||||
// Assert.assertEquals((long)data.getIntegerData(), 1L);
|
||||
// Assert.assertEquals((long)data.getShortData(), 1L);
|
||||
// Assert.assertEquals((long)data.getByteData(), 1L);
|
||||
// Assert.assertEquals(data.getDoubleData(), 1.0, 0.0);
|
||||
// Assert.assertEquals(data.getFloatData(), (float)1.0, 0.0);
|
||||
// Assert.assertEquals(data.getString(), "测试");
|
||||
LOGGER.debug("First row:{}", JSON.toJSONString(list.get(0))); |
||||
} |
||||
} |
@ -1,53 +0,0 @@
|
||||
package com.alibaba.easyexcel.test.core.converter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author zhuangjiaju |
||||
*/ |
||||
@Data |
||||
public class ReadConverterData { |
||||
@ExcelProperty("日期") |
||||
private Date date; |
||||
@ExcelProperty("日期字符串") |
||||
private String dateString; |
||||
@ExcelProperty("布尔") |
||||
private Boolean booleanData; |
||||
@ExcelProperty("布尔字符串") |
||||
private String booleanString; |
||||
@ExcelProperty("大数") |
||||
private BigDecimal bigDecimal; |
||||
@ExcelProperty("大数字符串") |
||||
private String bigDecimalString; |
||||
@ExcelProperty("长整型") |
||||
private Long longData; |
||||
@ExcelProperty("长整型字符串") |
||||
private String longString; |
||||
@ExcelProperty("整型") |
||||
private Integer integerData; |
||||
@ExcelProperty("整型字符串") |
||||
private String integerString; |
||||
@ExcelProperty("短整型") |
||||
private Short shortData; |
||||
@ExcelProperty("短整型字符串") |
||||
private String shortString; |
||||
@ExcelProperty("字节型") |
||||
private Byte byteData; |
||||
@ExcelProperty("字节型字符串") |
||||
private String byteString; |
||||
@ExcelProperty("双精度浮点型") |
||||
private Double doulbleData; |
||||
@ExcelProperty("双精度浮点型字符串") |
||||
private String doulbleString; |
||||
@ExcelProperty("浮点型") |
||||
private Float FloatData; |
||||
@ExcelProperty("浮点型字符串") |
||||
private String FloatString; |
||||
@ExcelProperty("字符串") |
||||
private String string; |
||||
} |
@ -1,4 +1,4 @@
|
||||
package com.alibaba.easyexcel.test.core.nohead; |
||||
package com.alibaba.easyexcel.test.core.head; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue