use of com.alibaba.excel.exception.ExcelAnalysisException in project easyexcel by alibaba.
the class CsvExcelReadExecutor method execute.
@Override
public void execute() {
CSVParser csvParser;
try {
csvParser = csvParser();
csvReadContext.csvReadWorkbookHolder().setCsvParser(csvParser);
} catch (IOException e) {
throw new ExcelAnalysisException(e);
}
for (ReadSheet readSheet : sheetList) {
readSheet = SheetUtils.match(readSheet, csvReadContext);
if (readSheet == null) {
continue;
}
csvReadContext.currentSheet(readSheet);
int rowIndex = 0;
for (CSVRecord record : csvParser) {
dealRecord(record, rowIndex++);
}
// The last sheet is read
csvReadContext.analysisEventProcessor().endSheet(csvReadContext);
}
}
use of com.alibaba.excel.exception.ExcelAnalysisException in project easyexcel by alibaba.
the class AnalysisContextImpl method currentSheet.
@Override
public void currentSheet(ReadSheet readSheet) {
switch(readWorkbookHolder.getExcelType()) {
case XLS:
readSheetHolder = new XlsReadSheetHolder(readSheet, readWorkbookHolder);
break;
case XLSX:
readSheetHolder = new XlsxReadSheetHolder(readSheet, readWorkbookHolder);
break;
case CSV:
readSheetHolder = new CsvReadSheetHolder(readSheet, readWorkbookHolder);
break;
default:
break;
}
currentReadHolder = readSheetHolder;
if (readWorkbookHolder.getHasReadSheet().contains(readSheetHolder.getSheetNo())) {
throw new ExcelAnalysisException("Cannot read sheet repeatedly.");
}
readWorkbookHolder.getHasReadSheet().add(readSheetHolder.getSheetNo());
if (log.isDebugEnabled()) {
log.debug("Began to read:{}", readSheetHolder);
}
}
Aggregations