EasyExcel的操作

设置行高,列宽,标题名,必填,忽略列,标题颜色等,详细看如下代码:

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import org.apache.poi.ss.usermodel.Font;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;


@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class User implements Serializable {

	private static final long serialVersionUID = 1L;

	@ExcelProperty("姓名")
	@HeadFontStyle(color = Font.COLOR_RED)
	@NotNull(message = "姓名不能为空")
	private String empName;

	/**
	 * 性别
	 */
	@ExcelIgnore
	private String gender;

	@ExcelProperty("家庭地址")
	private String address;


}

你可能感兴趣的:(Java基础,Java,web开发,python,开发语言)