自定格式常量类
java
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
java
@ExcelProperty("物料的单公斤成本(元/千克)")
@NumberFormat(ExcelFormatConstants.NUMBER_FORMAT_FOUR_DECIMAL)
private BigDecimal weightCost;
若依的excel 使用注解@Exce属性numberFormat
java
@Excel(name = "产出重量",numberFormat = ExcelFormatConstants.NUMBER_FORMAT_DEFAULT, cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT)
private BigDecimal weightOut;