use of com.alibaba.excel.read.metadata.ReadSheet 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.read.metadata.ReadSheet in project easyexcel by alibaba.
the class BofRecordHandler method initReadSheetDataList.
private void initReadSheetDataList(XlsReadWorkbookHolder xlsReadWorkbookHolder) {
if (xlsReadWorkbookHolder.getActualSheetDataList() != null) {
return;
}
BoundSheetRecord[] boundSheetRecords = BoundSheetRecord.orderByBofPosition(xlsReadWorkbookHolder.getBoundSheetRecordList());
List<ReadSheet> readSheetDataList = new ArrayList<ReadSheet>();
for (int i = 0; i < boundSheetRecords.length; i++) {
BoundSheetRecord boundSheetRecord = boundSheetRecords[i];
ReadSheet readSheet = new ReadSheet(i, boundSheetRecord.getSheetname());
readSheetDataList.add(readSheet);
}
xlsReadWorkbookHolder.setActualSheetDataList(readSheetDataList);
// Just need to get the list of sheets
if (!xlsReadWorkbookHolder.getNeedReadSheet()) {
throw new ExcelAnalysisStopException("Just need to get the list of sheets.");
}
}
use of com.alibaba.excel.read.metadata.ReadSheet in project easyexcel by alibaba.
the class RepeatTest method hh2.
@Test
public void hh2() throws IOException {
ExcelReader reader = EasyExcel.read(new FileInputStream("D:\\test\\sheet.xls"), LockData.class, new RepeatListener()).headRowNumber(0).build();
ReadSheet r2 = EasyExcel.readSheet(1).build();
reader.read(r2);
reader.finish();
}
use of com.alibaba.excel.read.metadata.ReadSheet in project easyexcel by alibaba.
the class RepeatTest method hh1.
@Test
public void hh1() throws IOException {
ExcelReader reader = EasyExcel.read(new FileInputStream("D:\\test\\hg2.xls"), LockData.class, new RepeatListener()).headRowNumber(0).build();
ReadSheet r2 = EasyExcel.readSheet(0).build();
reader.read(r2);
reader.finish();
}
use of com.alibaba.excel.read.metadata.ReadSheet in project easyexcel by alibaba.
the class XlsxSaxAnalyser method execute.
@Override
public void execute() {
for (ReadSheet readSheet : sheetList) {
readSheet = SheetUtils.match(readSheet, xlsxReadContext);
if (readSheet != null) {
xlsxReadContext.currentSheet(readSheet);
parseXmlSource(sheetMap.get(readSheet.getSheetNo()), new XlsxRowHandler(xlsxReadContext));
// Read comments
readComments(readSheet);
// The last sheet is read
xlsxReadContext.analysisEventProcessor().endSheet(xlsxReadContext);
}
}
}
Aggregations