类 AxolotlStreamExcelReader<T>

java.lang.Object
cn.toutatis.xvoid.axolotl.excel.reader.support.AxolotlAbstractExcelReader<T>
cn.toutatis.xvoid.axolotl.excel.reader.AxolotlStreamExcelReader<T>
类型参数:
T - 转换实体

public class AxolotlStreamExcelReader<T> extends AxolotlAbstractExcelReader<T>
Excel流形式读取器

大文件读取时,推荐使用流形式读取器,相比于AxolotlExcelReader内存占用实际上没什么区别,但是读取速度更快。

对于AxolotlStreamExcelReader读取数据时,少了很多特性支持,不支持分页等,因为流形式读取器读取时,不会将整个文件读入内存。

流支持基于excel-streaming-reader,并且该流读取器只支持xlsx格式

excel-streaming-reader在底层使用了一些Apache POI代码。该代码在处理xlsx时使用内存和/或临时文件来存储临时数据。对于非常大的文件,您可能希望使用临时文件。

对于StreamingReader.builder(),不要设置setAvoidTempFiles(true)。您还应该考虑调优POI设置。具体来说,请考虑设置这些属性:

ZipInputStreamZipEntrySource.setThresholdBytesForTempFiles(16384); //16KB

ZipPackage.setUseTempFilePackageParts(true);

从以下版本开始:
0.0.9-ALPHA-1
作者:
Toutatis_Gc
  • 构造器详细资料

    • AxolotlStreamExcelReader

      public AxolotlStreamExcelReader(File excelFile)
    • AxolotlStreamExcelReader

      public AxolotlStreamExcelReader(File excelFile, boolean withDefaultConfig)
    • AxolotlStreamExcelReader

      public AxolotlStreamExcelReader(File excelFile, Class<T> clazz)
    • AxolotlStreamExcelReader

      public AxolotlStreamExcelReader(InputStream ins)
    • AxolotlStreamExcelReader

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

      public AxolotlStreamExcelReader(File excelFile, Class<T> clazz, boolean withDefaultConfig)
  • 方法详细资料

    • checkFileFormat

      protected DetectResult checkFileFormat(File file, InputStream ins)
      检查文件类型 流方式仅支持xlsx格式
      覆盖:
      checkFileFormat 在类中 AxolotlAbstractExcelReader<T>
      参数:
      file - 工作簿文件
      ins - 输入流
      返回:
      文件检测结果
    • loadFileDataToWorkBook

      protected void loadFileDataToWorkBook()
      加载大文件
      覆盖:
      loadFileDataToWorkBook 在类中 AxolotlAbstractExcelReader<T>
    • castRow2Instance

      public <RT> RT castRow2Instance(org.apache.poi.ss.usermodel.Row row, ReaderConfig<RT> readerConfig)
      读取行数据转换为对象
      类型参数:
      RT - 对象类型
      参数:
      row - 行
      readerConfig - 读取配置
      返回:
      对象
    • dataIterator

      public <RT> AxolotlExcelStream<RT> dataIterator(ReaderConfig<RT> readerConfig)
      数据迭代器
      类型参数:
      RT - 对象类型
      参数:
      readerConfig - 读取配置
      返回:
      数据迭代器