类 AxolotlAbstractExcelReader<T>

java.lang.Object
cn.toutatis.xvoid.axolotl.excel.reader.support.AxolotlAbstractExcelReader<T>
直接已知子类:
AxolotlExcelReader, AxolotlStreamExcelReader

public abstract class AxolotlAbstractExcelReader<T> extends Object
  • 字段详细资料

    • LOGGER

      protected org.slf4j.Logger LOGGER
      日志工具
    • workBookContext

      protected WorkBookContext workBookContext
      工作簿元信息
    • validator

      protected javax.validation.Validator validator
      JSR-303校验器 使用Hibernate实现的校验器完成对读取数据的验证
    • _sheetLevelReaderConfig

      protected ReaderConfig<T> _sheetLevelReaderConfig
      [内部属性] 直接指定读取的类 在读取数据时使用不指定读取类型的读取方法时,使用该类读取数据
  • 构造器详细资料

    • AxolotlAbstractExcelReader

      public AxolotlAbstractExcelReader(File excelFile)
      构造文件读取器
    • AxolotlAbstractExcelReader

      public AxolotlAbstractExcelReader(File excelFile, boolean withDefaultConfig)
      构造文件读取器
      参数:
      excelFile - 工作簿文件
      withDefaultConfig - 是否使用默认配置
    • AxolotlAbstractExcelReader

      public AxolotlAbstractExcelReader(File excelFile, Class<T> clazz)
      构造文件读取器
      参数:
      excelFile - 工作簿文件
      clazz - 读取的类
    • AxolotlAbstractExcelReader

      public AxolotlAbstractExcelReader(InputStream ins)
      [ROOT] 流支持构造
      参数:
      ins - 文件流
    • AxolotlAbstractExcelReader

      public AxolotlAbstractExcelReader(InputStream ins, Class<T> clazz)
    • AxolotlAbstractExcelReader

      public AxolotlAbstractExcelReader(File excelFile, Class<T> clazz, boolean withDefaultConfig)
      [ROOT] 构造文件读取器 初始化读取Excel文件 1.初始化加载文件先判断文件是否正常并且是需要的格式 2.将文件加载到POI工作簿中
      参数:
      excelFile - Excel工作簿文件
      withDefaultConfig - 是否使用默认配置
  • 方法详细资料

    • createAdditionalExtensions

      protected void createAdditionalExtensions()
      [ROOT] 创建额外扩展 可能会计划出一些扩展功能
    • checkFileFormat

      protected DetectResult checkFileFormat(File file, InputStream ins)
      [内部方法] 检查文件格式
    • getFileOrStreamDetectResult

      protected DetectResult getFileOrStreamDetectResult(File file, InputStream ins, org.apache.tika.mime.MimeType mimeType)
      [内部方法]
      参数:
      file - 文件
      ins - 流
      mimeType - 媒体类型
      返回:
      检查结果
    • loadFileDataToWorkBook

      protected void loadFileDataToWorkBook()
      [内部方法] 加载文件并读取数据创建Workbook
    • readSheetDataAsObject

      public <RT> RT readSheetDataAsObject(ReadConfigBuilder<RT> readerConfigBuilder)
      读取Excel工作表为一个实体
      类型参数:
      RT - 读取类型
      参数:
      readerConfigBuilder - 读取配置构建器
      返回:
      读取的数据
      另请参阅:
    • readSheetDataAsObject

      public <RT> RT readSheetDataAsObject(ReaderConfig<RT> readerConfig)
      [ROOT] 读取Excel工作表为一个实体
      类型参数:
      RT - 读取类型
      参数:
      readerConfig - 读取配置
      返回:
      读取的数据
      另请参阅:
    • searchSheet

      protected org.apache.poi.ss.usermodel.Sheet searchSheet(ReaderConfig<?> readerConfig)
      参数:
      readerConfig - 读取配置
    • spreadMergedCells

      protected void spreadMergedCells(org.apache.poi.ss.usermodel.Sheet sheet)
      处理合并单元格
      参数:
      sheet - 工作表
    • searchHeaderCellPosition

      protected void searchHeaderCellPosition(ReaderConfig<?> readerConfig)
      查找表头
      参数:
      readerConfig - 读取配置
      另请参阅:
    • readRow

      protected <RT> RT readRow(org.apache.poi.ss.usermodel.Sheet sheet, int rowNumber, ReaderConfig<RT> readerConfig)
      [ROOT] 读取行信息到对象
      类型参数:
      RT - 转换类型
      参数:
      sheet - 表
      rowNumber - 行号
      readerConfig - 读取配置
    • convertCellToInstance

      protected <RT> void convertCellToInstance(org.apache.poi.ss.usermodel.Row row, RT instance, ReaderConfig<RT> readerConfig)
      参数:
      readerConfig - 读取配置
    • row2SimplePOJO

      protected <RT> void row2SimplePOJO(RT instance, org.apache.poi.ss.usermodel.Row row, ReaderConfig<RT> readerConfig)
      填充单元格数据到Java对象
      类型参数:
      RT - 读取类型
      参数:
      instance - 对象实例
      row - 行
      readerConfig - 读取配置
    • convertPositionCellToInstance

      protected void convertPositionCellToInstance(Object instance, ReaderConfig<?> readerConfig, org.apache.poi.ss.usermodel.Sheet sheet)
      参数:
      readerConfig - 读取配置
    • assignValueToField

      protected void assignValueToField(Object instance, Object adaptiveValue, EntityCellMappingInfo<?> mappingInfo, ReaderConfig<?> readerConfig)
      [ROOT] 讲适配后的值赋值给实体类字段
      参数:
      instance - 实体类实例
      adaptiveValue - 适配后的值
      mappingInfo - 映射信息
      readerConfig - 读取配置
    • adaptiveCellValue2EntityClass

      protected Object adaptiveCellValue2EntityClass(CellGetInfo info, EntityCellMappingInfo<?> mappingInfo, ReaderConfig<?> readerConfig)
      [ROOT] 适配实体类的字段
      参数:
      info - 单元格值
      mappingInfo - 映射信息
      readerConfig - 读取配置
      返回:
      适配实体类的字段值
    • adaptiveValue

      protected Object adaptiveValue(DataCastAdapter<Object> adapter, CellGetInfo info, EntityCellMappingInfo<Object> mappingInfo, ReaderConfig<Object> readerConfig)
      参数:
      readerConfig - 读取配置
    • castValue

      protected Object castValue(DataCastAdapter<Object> adapter, CellGetInfo info, EntityCellMappingInfo<Object> mappingInfo)
    • getPositionCellOriginalValue

      protected CellGetInfo getPositionCellOriginalValue(org.apache.poi.ss.usermodel.Sheet sheet, EntityCellMappingInfo<?> mappingInfo)
      获取位置映射单元格原始值
      参数:
      sheet - 表
      mappingInfo - 映射信息
      返回:
      单元格值
    • getCellOriginalValue

      protected CellGetInfo getCellOriginalValue(org.apache.poi.ss.usermodel.Row row, int index, EntityCellMappingInfo<?> mappingInfo)
      获取单元格原始值
      参数:
      row - 行次
      mappingInfo - 映射信息
      返回:
      单元格值
      另请参阅:
    • getIndexCellValue

      protected CellGetInfo getIndexCellValue(org.apache.poi.ss.usermodel.Row row, int index, EntityCellMappingInfo<?> mappingInfo)
      获取索引映射单元格值
      参数:
      row - 行次
      mappingInfo - 映射信息
      返回:
      单元格值
      另请参阅:
    • getBlankCellValue

      protected CellGetInfo getBlankCellValue(EntityCellMappingInfo<?> mappingInfo)
      获取空单元格值
      参数:
      mappingInfo - 映射信息
      返回:
      默认填充值
    • row2MapInstance

      protected <RT> void row2MapInstance(Map<String,Object> instance, org.apache.poi.ss.usermodel.Row row, ReaderConfig<RT> readerConfig)
      [ROOT] 填充单元格数据到map
      参数:
      readerConfig - 读取配置
    • validateConvertEntity

      protected <RT> void validateConvertEntity(RT instance, boolean isValidate)
      校验读取实体是否符合验证规则
    • preCheckAndFixReadConfig

      protected void preCheckAndFixReadConfig(ReaderConfig<?> readerConfig)
      [ROOT] 预校验读取配置是否正常 不正常的数据将被修正
      参数:
      readerConfig - 读取配置
    • getFormulaCellValue

      protected CellGetInfo getFormulaCellValue(org.apache.poi.ss.usermodel.Cell cell)
      [ROOT] 计算单元格公式为结果
      参数:
      cell - 单元格
      返回:
      计算结果
    • getPhysicalRowNumber

      public int getPhysicalRowNumber()
    • getRecordRowNumber

      public int getRecordRowNumber()
    • getRowNumber

      public int getRowNumber(boolean isPhysical)
      获取行数
      参数:
      isPhysical - 是否是物理行数
      返回:
      行数
    • getRowNumber

      public int getRowNumber(ReaderConfig<?> readerConfig, boolean isPhysical)
      获取行数
      参数:
      readerConfig - 读取配置
      isPhysical - 是否是物理行数
      返回:
      行数
    • getPhysicalRowNumber

      public int getPhysicalRowNumber(ReaderConfig<?> readerConfig)
      参数:
      readerConfig - 读取配置
    • getRecordRowNumber

      public int getRecordRowNumber(ReaderConfig<?> readerConfig)
      参数:
      readerConfig - 读取配置
    • getRowNumber

      public int getRowNumber(int sheetIndex, boolean isPhysical)
      [ROOT] 获取行数
      参数:
      sheetIndex - 表索引
      isPhysical - 是否是物理行数
      返回:
      行数
    • getHumanReadablePosition

      public String getHumanReadablePosition()
      获取当前读取位置