|
楼主 |
发表于 2013-6-4 19:09:12
|
显示全部楼层
导出好了,字段范围查询也好了,导入死活不行
@RequestMapping(params = "goImplXls")
public ModelAndView goImplXls(HttpServletRequest request) {
return new ModelAndView("jeecg/test/maintain/upload");
}
// 统一的Excel上传导入方式
@RequestMapping(params = "importExcel", method = RequestMethod.POST)
@ResponseBody
public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
List<MaintainEntity> maintainLists;
try {
maintainLists = (List<MaintainEntity>) ExcelUtil.importExcelByIs(file.getInputStream(), MaintainEntity.class);
for (MaintainEntity maintainList : maintainLists) {
maintainList.setId(UUID.randomUUID().toString());
maintainService.save(maintainList);
}
j.setMsg("文件导入成功!");
} catch (IOException e) {
j.setMsg("文件导入失败!");
logger.error(ExceptionUtil.getExceptionMessage(e));
}
//break; // 不支持多个文件导入?
}
return j;
} |
|