本文主要是介绍EasyExcel自定义数据格式化,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
自定格式常量类
public class ExcelFormatConstants {public static final String DATE_FORMAT = "yyyy-MM-dd";public static final String NUMBER_FORMAT_DEFAULT = "#,##0.00";public static final String NUMBER_FORMAT_FOUR_DECIMAL = "#,##0.0000";public static final String NUMBER_FORMAT_TEN_DECIMAL = "#,##0.0000000000";public static final String SEPARATOR = ",";public static final int SCALE = -1;}
EasyExcel使用注解@NumberFormat
@ExcelProperty("物料的单公斤成本(元/千克)")
@NumberFormat(ExcelFormatConstants.NUMBER_FORMAT_FOUR_DECIMAL)
private BigDecimal weightCost;
若依的excel 使用注解@Exce属性numberFormat
@Excel(name = "产出重量",numberFormat = ExcelFormatConstants.NUMBER_FORMAT_DEFAULT, cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT)
private BigDecimal weightOut;
这篇关于EasyExcel自定义数据格式化的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!