@PostMapping(value = "/importForcartData", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@ApiOperation(value = "批量导入数据", produces = MimeTypeUtils.APPLICATION_JSON_VALUE, httpMethod = "POST")
public JsonResult importGoods(@ApiParam(value = "导入的Excel", required = true) @RequestParam ("file")MultipartFile file,@RequestParam("userId") long userId) throws IOException {
if (file.isEmpty() || file.equals("")) {
throw new ServiceException("请选择要导入的excel");
}
InputStream inputStream = file.getInputStream();
List<ImportGoodsModel> technicialExcels = NewExcelUtils.importStreamExcel(inputStream, ImportGoodsModel.class);
}
public static <T> List<T> importStreamExcel(InputStream inputStream, Class dataClass) throws IOException {
XSSFWorkbook workbook = null;
try {
workbook = new XSSFWorkbook(inputStream);
} catch (Exception var4) {
workbook = new XSSFWorkbook(inputStream);
}
return workbook(workbook, dataClass);
}
解析Excel
最新推荐文章于 2022-08-22 11:25:52 发布