Apache POI 4.0.1版本读取Excel文件并写入数据库(兼容 xls 和 xlsx)(五)

读取Excel文件并写入数据库,一般这种业务,经常会碰到。

ExcelBean

package com.springbootemaildemo.excel.c;

import io.swagger.annotations.ApiModelProperty;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;

public class ExcelBean {
    @ApiModelProperty(value = "列头(标题)名")
    private String headTextName;
    @ApiModelProperty(value = "对应字段名")
    private String propertyName;
    @ApiModelProperty(value = "合并单元格数")
    private Integer cols;
    @ApiModelProperty(value = "excel列设置风格")
    private XSSFCellStyle cellStyle;

    public ExcelBean() {
    }

    public ExcelBean(String headTextName, String propertyName, Integer cols, XSSFCellStyle cellStyle) {
        this.headTextName = headTextName;
        this.propertyName = propertyName;
        this.cols = cols;
        this.cellStyle = cellStyle;
    }

    public ExcelBean(String headTextName, String propertyName) {
        this.headTextName = headTextName;
        this.propertyName = propertyName;
    }

    public ExcelBean(String headTextName, String propertyName, Integer cols) {
        super();
        this.headTextName = headTextName;
        this.propertyName = propertyName;
        this.cols = cols;
    }

    public String getHeadTextName() {
        return headTextName;
    }

    public void setHeadTextName(String headTextName) {
        this.headTextName = headTextName;
    }

    public String getPropertyName() {
        return propertyName;
    }

    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }

    public Integer getCols() {
        return cols;
    }

    public void setCols(Integer cols) {
        this.cols = cols;
    }

    public XSSFCellStyle getCellStyle() {
        return cellStyle;
    }

    public void setCellStyle(XSSFCellStyle cellStyle) {
        this.cellStyle = cellStyle;
    }
}

 

上一篇:com.itextpdf.layout.Style


下一篇:使用NPOI导出Excel 并设置Excel样式(合并单元格、行高、宽度、字体、边框、位置)...