use of com.qiuyj.excel.importer.BeanExcelImporter in project qiuyj-code by qiuyuanjun.
the class ExcelOpsFactory method getExcelImporter.
@SuppressWarnings("unchecked")
public static ExcelImporter getExcelImporter(InputStream in, Class<?> beanCls) {
Objects.requireNonNull(in);
Workbook wb;
try {
wb = WorkbookFactory.create(in);
} catch (InvalidFormatException | IOException e) {
// 关闭流
StreamUtils.closeQuietly(in);
throw new IllegalStateException("Error parsing excel file.\n Caused by: " + e, e);
}
if (Objects.isNull(beanCls)) {
return new MapExcelImporter(wb);
} else {
return new BeanExcelImporter(wb, beanCls);
}
}
Aggregations