|
@ -7,6 +7,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams; |
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; |
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; |
|
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|
|
|
|
|
import cn.afterturn.easypoi.excel.imports.ExcelImportService; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
@ -228,6 +229,27 @@ public class ExcelPoiUtils { |
|
|
throw new IOException(e.getMessage()); |
|
|
throw new IOException(e.getMessage()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static <T> ExcelImportResult<T> importExcel1(InputStream inputStream, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|
|
|
|
|
if (inputStream == null) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
|
|
params.setTitleRows(titleRows); |
|
|
|
|
|
params.setHeadRows(headerRows); |
|
|
|
|
|
params.setSaveUrl("/tmp/excel/"); |
|
|
|
|
|
params.setNeedSave(false); |
|
|
|
|
|
try { |
|
|
|
|
|
// return ExcelImportUtil.importExcel(inputStream, pojoClass, params);
|
|
|
|
|
|
return (new ExcelImportService()).importExcelByIs(inputStream, pojoClass, params, false); |
|
|
|
|
|
} catch (NoSuchElementException e) { |
|
|
|
|
|
throw new IOException("excel文件不能为空"); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new IOException(e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* excel 导入,有错误信息 |
|
|
* excel 导入,有错误信息 |
|
|
* |
|
|
* |
|
|