类 AxolotlAbstractExcelReader<T>
java.lang.Object
cn.toutatis.xvoid.axolotl.excel.reader.support.AxolotlAbstractExcelReader<T>
-
字段概要
字段修饰符和类型字段说明protected ReaderConfig<T>[内部属性] 直接指定读取的类 在读取数据时使用不指定读取类型的读取方法时,使用该类读取数据protected org.slf4j.Logger日志工具protected javax.validation.ValidatorJSR-303校验器 使用Hibernate实现的校验器完成对读取数据的验证protected WorkBookContext工作簿元信息 -
构造器概要
构造器构造器说明AxolotlAbstractExcelReader(File excelFile) 构造文件读取器AxolotlAbstractExcelReader(File excelFile, boolean withDefaultConfig) 构造文件读取器AxolotlAbstractExcelReader(File excelFile, Class<T> clazz) 构造文件读取器AxolotlAbstractExcelReader(File excelFile, Class<T> clazz, boolean withDefaultConfig) [ROOT] 构造文件读取器 初始化读取Excel文件 1.初始化加载文件先判断文件是否正常并且是需要的格式 2.将文件加载到POI工作簿中[ROOT] 流支持构造AxolotlAbstractExcelReader(InputStream ins, Class<T> clazz) -
方法概要
修饰符和类型方法说明protected ObjectadaptiveCellValue2EntityClass(CellGetInfo info, EntityCellMappingInfo<?> mappingInfo, ReaderConfig<?> readerConfig) [ROOT] 适配实体类的字段protected ObjectadaptiveValue(DataCastAdapter<Object> adapter, CellGetInfo info, EntityCellMappingInfo<Object> mappingInfo, ReaderConfig<Object> readerConfig) protected voidassignValueToField(Object instance, Object adaptiveValue, EntityCellMappingInfo<?> mappingInfo, ReaderConfig<?> readerConfig) [ROOT] 讲适配后的值赋值给实体类字段protected ObjectcastValue(DataCastAdapter<Object> adapter, CellGetInfo info, EntityCellMappingInfo<Object> mappingInfo) protected DetectResultcheckFileFormat(File file, InputStream ins) [内部方法] 检查文件格式protected <RT> voidconvertCellToInstance(org.apache.poi.ss.usermodel.Row row, RT instance, ReaderConfig<RT> readerConfig) protected voidconvertPositionCellToInstance(Object instance, ReaderConfig<?> readerConfig, org.apache.poi.ss.usermodel.Sheet sheet) protected void[ROOT] 创建额外扩展 可能会计划出一些扩展功能protected CellGetInfogetBlankCellValue(EntityCellMappingInfo<?> mappingInfo) 获取空单元格值protected CellGetInfogetCellOriginalValue(org.apache.poi.ss.usermodel.Row row, int index, EntityCellMappingInfo<?> mappingInfo, ReaderConfig<?> readerConfig) 获取单元格原始值protected DetectResultgetFileOrStreamDetectResult(File file, InputStream ins, org.apache.tika.mime.MimeType mimeType) [内部方法]protected CellGetInfogetFormulaCellValue(org.apache.poi.ss.usermodel.Cell cell) [ROOT] 计算单元格公式为结果获取当前读取位置protected CellGetInfogetIndexCellValue(org.apache.poi.ss.usermodel.Row row, int index, EntityCellMappingInfo<?> mappingInfo, ReaderConfig<?> readerConfig) 获取索引映射单元格值intintgetPhysicalRowNumber(ReaderConfig<?> readerConfig) protected CellGetInfogetPositionCellOriginalValue(org.apache.poi.ss.usermodel.Sheet sheet, EntityCellMappingInfo<?> mappingInfo) 获取位置映射单元格原始值intintgetRecordRowNumber(ReaderConfig<?> readerConfig) intgetRowNumber(boolean isPhysical) 获取行数intgetRowNumber(int sheetIndex, boolean isPhysical) [ROOT] 获取行数intgetRowNumber(ReaderConfig<?> readerConfig, boolean isPhysical) 获取行数protected void[内部方法] 加载文件并读取数据创建Workbookprotected voidpreCheckAndFixReadConfig(ReaderConfig<?> readerConfig) [ROOT] 预校验读取配置是否正常 不正常的数据将被修正protected <RT> RTreadRow(org.apache.poi.ss.usermodel.Sheet sheet, int rowNumber, ReaderConfig<RT> readerConfig) [ROOT] 读取行信息到对象<RT> RTreadSheetDataAsObject(ReadConfigBuilder<RT> readerConfigBuilder) 读取Excel工作表为一个实体<RT> RTreadSheetDataAsObject(ReaderConfig<RT> readerConfig) [ROOT] 读取Excel工作表为一个实体protected <RT> voidrow2MapInstance(Map<String, Object> instance, org.apache.poi.ss.usermodel.Row row, ReaderConfig<RT> readerConfig) [ROOT] 填充单元格数据到mapprotected <RT> voidrow2SimplePOJO(RT instance, org.apache.poi.ss.usermodel.Row row, ReaderConfig<RT> readerConfig) 填充单元格数据到Java对象protected voidsearchHeaderCellPosition(ReaderConfig<?> readerConfig) 查找表头protected org.apache.poi.ss.usermodel.SheetsearchSheet(ReaderConfig<?> readerConfig) protected voidspreadMergedCells(org.apache.poi.ss.usermodel.Sheet sheet, ReaderConfig<?> readerConfig) 处理合并单元格protected <RT> voidvalidateConvertEntity(RT instance, boolean isValidate) 校验读取实体是否符合验证规则
-
字段详细资料
-
LOGGER
protected org.slf4j.Logger LOGGER日志工具 -
workBookContext
工作簿元信息 -
validator
protected javax.validation.Validator validatorJSR-303校验器 使用Hibernate实现的校验器完成对读取数据的验证 -
_sheetLevelReaderConfig
[内部属性] 直接指定读取的类 在读取数据时使用不指定读取类型的读取方法时,使用该类读取数据
-
-
构造器详细资料
-
AxolotlAbstractExcelReader
构造文件读取器 -
AxolotlAbstractExcelReader
构造文件读取器- 参数:
excelFile- 工作簿文件withDefaultConfig- 是否使用默认配置
-
AxolotlAbstractExcelReader
构造文件读取器- 参数:
excelFile- 工作簿文件clazz- 读取的类
-
AxolotlAbstractExcelReader
[ROOT] 流支持构造- 参数:
ins- 文件流
-
AxolotlAbstractExcelReader
-
AxolotlAbstractExcelReader
[ROOT] 构造文件读取器 初始化读取Excel文件 1.初始化加载文件先判断文件是否正常并且是需要的格式 2.将文件加载到POI工作簿中- 参数:
excelFile- Excel工作簿文件withDefaultConfig- 是否使用默认配置
-
-
方法详细资料
-
createAdditionalExtensions
protected void createAdditionalExtensions()[ROOT] 创建额外扩展 可能会计划出一些扩展功能 -
checkFileFormat
[内部方法] 检查文件格式 -
getFileOrStreamDetectResult
protected DetectResult getFileOrStreamDetectResult(File file, InputStream ins, org.apache.tika.mime.MimeType mimeType) [内部方法]- 参数:
file- 文件ins- 流mimeType- 媒体类型- 返回:
- 检查结果
-
loadFileDataToWorkBook
protected void loadFileDataToWorkBook()[内部方法] 加载文件并读取数据创建Workbook -
readSheetDataAsObject
读取Excel工作表为一个实体- 类型参数:
RT- 读取类型- 参数:
readerConfigBuilder- 读取配置构建器- 返回:
- 读取的数据
- 另请参阅:
-
readSheetDataAsObject
[ROOT] 读取Excel工作表为一个实体- 类型参数:
RT- 读取类型- 参数:
readerConfig- 读取配置- 返回:
- 读取的数据
- 另请参阅:
-
searchSheet
- 参数:
readerConfig- 读取配置
-
spreadMergedCells
protected void spreadMergedCells(org.apache.poi.ss.usermodel.Sheet sheet, ReaderConfig<?> readerConfig) 处理合并单元格- 参数:
sheet- 工作表- 另请参阅:
-
searchHeaderCellPosition
查找表头- 参数:
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, ReaderConfig<?> readerConfig) 获取单元格原始值- 参数:
row- 行次mappingInfo- 映射信息- 返回:
- 单元格值
- 另请参阅:
-
getIndexCellValue
protected CellGetInfo getIndexCellValue(org.apache.poi.ss.usermodel.Row row, int index, EntityCellMappingInfo<?> mappingInfo, ReaderConfig<?> readerConfig) 获取索引映射单元格值- 参数:
row- 行次mappingInfo- 映射信息- 返回:
- 单元格值
- 另请参阅:
-
getBlankCellValue
获取空单元格值- 参数:
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
[ROOT] 预校验读取配置是否正常 不正常的数据将被修正- 参数:
readerConfig- 读取配置
-
getFormulaCellValue
[ROOT] 计算单元格公式为结果- 参数:
cell- 单元格- 返回:
- 计算结果
-
getPhysicalRowNumber
public int getPhysicalRowNumber() -
getRecordRowNumber
public int getRecordRowNumber() -
getRowNumber
public int getRowNumber(boolean isPhysical) 获取行数- 参数:
isPhysical- 是否是物理行数- 返回:
- 行数
-
getRowNumber
获取行数- 参数:
readerConfig- 读取配置isPhysical- 是否是物理行数- 返回:
- 行数
-
getPhysicalRowNumber
- 参数:
readerConfig- 读取配置
-
getRecordRowNumber
- 参数:
readerConfig- 读取配置
-
getRowNumber
public int getRowNumber(int sheetIndex, boolean isPhysical) [ROOT] 获取行数- 参数:
sheetIndex- 表索引isPhysical- 是否是物理行数- 返回:
- 行数
-
getHumanReadablePosition
获取当前读取位置
-