use of com.alibaba.excel.ExcelReader in project easyexcel by alibaba.
the class RepeatTest method hh.
@Test
public void hh() throws IOException {
ExcelReader reader = EasyExcel.read(new FileInputStream("D:\\test\\hg2.xls"), LockData.class, new RepeatListener()).headRowNumber(0).build();
ReadSheet r1 = EasyExcel.readSheet(0).build();
ReadSheet r2 = EasyExcel.readSheet(2).build();
reader.read(r1);
reader.read(r2);
reader.finish();
}
use of com.alibaba.excel.ExcelReader in project easyexcel by alibaba.
the class MultipleSheetsDataTest method read.
private void read(File file) {
MultipleSheetsListener multipleSheetsListener = new MultipleSheetsListener();
try (ExcelReader excelReader = EasyExcel.read(file, MultipleSheetsData.class, multipleSheetsListener).build()) {
List<ReadSheet> sheets = excelReader.excelExecutor().sheetList();
int count = 1;
for (ReadSheet readSheet : sheets) {
excelReader.read(readSheet);
Assert.assertEquals(multipleSheetsListener.getList().size(), count);
count++;
}
}
}
use of com.alibaba.excel.ExcelReader in project easyexcel by alibaba.
the class RepetitionDataTest method readAndWrite.
private void readAndWrite(File file) {
try (ExcelWriter excelWriter = EasyExcel.write(file, RepetitionData.class).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet(0).build();
excelWriter.write(data(), writeSheet).write(data(), writeSheet);
}
try (ExcelReader excelReader = EasyExcel.read(file, RepetitionData.class, new RepetitionDataListener()).build()) {
ReadSheet readSheet = EasyExcel.readSheet(0).build();
excelReader.read(readSheet);
}
}
use of com.alibaba.excel.ExcelReader in project easyexcel by alibaba.
the class RepetitionDataTest method readAndWriteTable.
private void readAndWriteTable(File file) {
try (ExcelWriter excelWriter = EasyExcel.write(file, RepetitionData.class).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet(0).build();
WriteTable writeTable = EasyExcel.writerTable(0).relativeHeadRowIndex(0).build();
excelWriter.write(data(), writeSheet, writeTable).write(data(), writeSheet, writeTable);
}
try (ExcelReader excelReader = EasyExcel.read(file, RepetitionData.class, new RepetitionDataListener()).build()) {
ReadSheet readSheet = EasyExcel.readSheet(0).headRowNumber(2).build();
excelReader.read(readSheet);
}
}
use of com.alibaba.excel.ExcelReader in project eden-architect by shiyindaxiaojie.
the class EasyExcelReader method read.
public <T> void read(@NonNull InputStream inputStream, @NonNull AnalysisEventListener<T> listener, int... sheetIndexs) {
ExcelReader excelReader = excelReader(inputStream, listener);
try {
if (sheetIndexs == null) {
excelReader.readAll();
} else {
List<ReadSheet> readSheets = new ArrayList<>();
for (int sheetIndex : sheetIndexs) {
readSheets.add(EasyExcel.readSheet(sheetIndex).build());
}
excelReader.read(readSheets);
}
} finally {
excelReader.finish();
}
}
Aggregations