use of com.alibaba.excel.read.builder.ExcelReaderBuilder in project easyexcel by alibaba.
the class EasyExcelFactory method read.
/**
* Build excel the read
*
* @param inputStream
* Input stream to read.
* @param head
* Annotate the class for configuration information.
* @param readListener
* Read listener.
* @return Excel reader builder.
*/
public static ExcelReaderBuilder read(InputStream inputStream, Class head, ReadListener readListener) {
ExcelReaderBuilder excelReaderBuilder = new ExcelReaderBuilder();
excelReaderBuilder.file(inputStream);
if (head != null) {
excelReaderBuilder.head(head);
}
if (readListener != null) {
excelReaderBuilder.registerReadListener(readListener);
}
return excelReaderBuilder;
}
use of com.alibaba.excel.read.builder.ExcelReaderBuilder in project easyexcel by alibaba.
the class EasyExcelFactory method read.
/**
* Build excel the read
*
* @param pathName
* File path to read.
* @param head
* Annotate the class for configuration information.
* @param readListener
* Read listener.
* @return Excel reader builder.
*/
public static ExcelReaderBuilder read(String pathName, Class head, ReadListener readListener) {
ExcelReaderBuilder excelReaderBuilder = new ExcelReaderBuilder();
excelReaderBuilder.file(pathName);
if (head != null) {
excelReaderBuilder.head(head);
}
if (readListener != null) {
excelReaderBuilder.registerReadListener(readListener);
}
return excelReaderBuilder;
}
use of com.alibaba.excel.read.builder.ExcelReaderBuilder in project kapcb-common by kapbc.
the class AnalyzeUtil method analyzeExcel.
/**
* analyze excel
*
* @param docPath String
* @param headRowNumber Integer
* @param modelClazz Class<? extends M>
* @param analyzeListener T
* @param <M> <M>
* @param <T> <T>
* @return T
*/
public static <M, T extends AnalysisEventListener<M>> T analyzeExcel(String docPath, Integer headRowNumber, Class<? extends M> modelClazz, T analyzeListener) {
if (StringUtils.isBlank(docPath)) {
throw new IllegalArgumentException("analyze excel param error, the doc path is : {}" + docPath);
}
String fileName = FileUtil.getPath() + docPath;
InputStream inputStream = null;
try {
inputStream = new FileInputStream(fileName);
} catch (FileNotFoundException e) {
log.error("analyze excel get io stream error, error message is : {}", e.getMessage());
}
ExcelReaderBuilder read = EasyExcelFactory.read(inputStream, modelClazz, analyzeListener);
if (Objects.nonNull(headRowNumber)) {
read.headRowNumber(headRowNumber);
}
ExcelReader build = read.build();
build.readAll();
build.finish();
return analyzeListener;
}
use of com.alibaba.excel.read.builder.ExcelReaderBuilder in project easyexcel by alibaba.
the class EasyExcelFactory method read.
/**
* Build excel the read
*
* @param file
* File to read.
* @param head
* Annotate the class for configuration information.
* @param readListener
* Read listener.
* @return Excel reader builder.
*/
public static ExcelReaderBuilder read(File file, Class head, ReadListener readListener) {
ExcelReaderBuilder excelReaderBuilder = new ExcelReaderBuilder();
excelReaderBuilder.file(file);
if (head != null) {
excelReaderBuilder.head(head);
}
if (readListener != null) {
excelReaderBuilder.registerReadListener(readListener);
}
return excelReaderBuilder;
}
use of com.alibaba.excel.read.builder.ExcelReaderBuilder in project chunjun by DTStack.
the class ExcelFileReadClient method open.
@Override
public void open(InputStream inputStream, FtpConfig ftpConfig) throws IOException {
cellCount = ftpConfig.getColumn().size();
ExcelReadListener listener = new ExcelReadListener();
queue = listener.getQueue();
ExcelReaderBuilder builder = EasyExcel.read(inputStream, listener);
if (!ftpConfig.getIsFirstLineHeader()) {
builder.headRowNumber(0);
}
builder.ignoreEmptyRow(true);
ExcelReader reader = builder.build();
sheetNum = reader.excelExecutor().sheetList().size();
executorService = new ThreadPoolExecutor(1, 1, 0, NANOSECONDS, new LinkedBlockingDeque<>(2), new BasicThreadFactory.Builder().namingPattern("excel-schedule-pool-%d").uncaughtExceptionHandler(new ExcelReaderExceptionHandler()).daemon(false).build());
ExcelReaderExecutor executor = new ExcelReaderExecutor(reader);
executorService.execute(executor);
}
Aggregations