Skip to content

按列读取

清沐 edited this page Nov 28, 2021 · 3 revisions

在某些特定场景下,仅需读取Excel文件中某一列,为避免构建模型等繁杂操作,特提供按列读取,具体如下:

支持直接读取为Byte、Short、Integer、Long、Float、Double、String

// 读取为字符串
List<String> strings = ColumnSaxExcelReader.columnNum(0)
             .rowFilter(row -> row.getRowNum() > 1)
             .readAsString(path.toFile());

// 读取为Integer
List<Integer> strings = ColumnSaxExcelReader.columnNum(0)
             .rowFilter(row -> row.getRowNum() > 1)
             .readAsInteger(path.toFile());

// 读取为Long
List<Long> strings = ColumnSaxExcelReader.columnNum(0)
             .rowFilter(row -> row.getRowNum() > 1)
             .readAsLong(path.toFile());
Clone this wiki locally