阿里easyExcel解析框架
EasyExcel框架
- Github: https://github.com/alibaba/easyexcel
- 官网: https://easyexcel.opensource.alibaba.com
- 官方文档: https://easyexcel.opensource.alibaba.com/docs/current/
常用注解
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface ExcelProperty {
/**
* 工作表标题的名称
*
* <p>
* write: 当你有多个头时它会自动合并
* <p>
* read: 当你有多个头时,取最后一个
*
* @return 工作表标题的名称
*/
String[] value() default {""};
/**
* 列索引 读取或写入列索引,如果等于-1,则按Java类排序。优先级:索引 > 顺序 > 默认排序
*
* @return 列索引
*/
int index() default -1;
/**
* 定义列的排序顺序。优先级:索引 > 顺序 > 默认排序
*
* @return 列顺序
*/
int order() default Integer.MAX_VALUE;
/**
* 当前属性强制使用此Converter。用于自定义转换
*
* @return Converter
*/
Class<? extends Converter<?>> converter() default AutoConverter.class;
/**
*
* 格式化 已经弃用
*
* @return 格式化字符串
* @deprecated 请用 {@link com.alibaba.excel.annotation.format.DateTimeFormat}
*/
@Deprecated
String format() default "";
}
/**
* 转换日期格式
*
* <p>
* write: 可以在 {@link java.util.Date} 上使用
* <p>
* read: 可以在 {@link String} 上使用
*
* @author Jiaju Zhuang
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface DateTimeFormat {
/**
*
* 特定格式参考 {@link java.text.SimpleDateFormat}
*
* @return 格式化字符串
*/
String value() default "";
/**
* 如果日期使用1904时间系统,则为True;如果使用1900时间系统,则为false。
*
* @return
*/
BooleanEnum use1904windowing() default BooleanEnum.DEFAULT;
}
导入
* 参考官方文档: https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read#%E4%BB%A3%E7%A0%81
导出
* 参考官方文档: https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write#%E4%BB%A3%E7%A0%81