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;
    }
}

猜你喜欢

转载自www.cnblogs.com/weigy/p/12944922.html