啦yes 发表于 2018-1-24 10:29:47

导入出错

这个是报错原因:
org.jeecgframework.poi.exception.excel.ExcelImportException: Excel 值获取失败
    at org.jeecgframework.poi.excel.imports.ExcelImportServer.importExcel(ExcelImportServer.java:219)
    at org.jeecgframework.poi.excel.imports.ExcelImportServer.importExcelByIs(ExcelImportServer.java:327)
    at org.jeecgframework.poi.excel.ExcelImportUtil.importExcel(ExcelImportUtil.java:85)
    at com.jeecg.erp_order.controller.ErpOrderController.importExcel(ErpOrderController.java:329)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:747)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:676)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.jeecgframework.core.aop.GZipFilter.doFilter(GZipFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:140)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.jeecgframework.poi.exception.excel.ExcelImportException: Excel 值获取失败
    at org.jeecgframework.poi.excel.imports.CellValueServer.getValueByType(CellValueServer.java:216)
    at org.jeecgframework.poi.excel.imports.CellValueServer.getValue(CellValueServer.java:131)
    at org.jeecgframework.poi.excel.imports.ExcelImportServer.saveFieldValue(ExcelImportServer.java:350)
    at org.jeecgframework.poi.excel.imports.ExcelImportServer.importExcel(ExcelImportServer.java:208)
    ... 54 more
导入报的错,以下是源代码
/**
      * 通过excel导入数据
      * @param request
      * @param
      * @return
      */
       @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();// 获取上传文件对象
               ImportParams params = new ImportParams();
               params.setTitleRows(2);
               params.setHeadRows(2);
               params.setNeedSave(true);
               try {
                   List<ErpOrderPage> list =ExcelImportUtil.importExcel(file.getInputStream(), ErpOrderPage.class, params);
                   ErpOrderEntity entity1=null;
                   for (ErpOrderPage page : list) {
                     entity1=new ErpOrderEntity();
                     MyBeanUtils.copyBeanNotNull2Bean(page,entity1);
                     erpOrderService.addMain(entity1, page.getErpSendList());
                   }
                   j.setMsg("文件导入成功!");
               } catch (Exception e) {
                   j.setMsg("文件导入失败!");
                   logger.error(ExceptionUtil.getExceptionMessage(e));
               }finally{
                   try {
                     file.getInputStream().close();
                   } catch (IOException e) {
                     e.printStackTrace();
                   }
               }
               }
               return j;
       }

啦yes 发表于 2018-1-24 10:45:29

这个是主表的实体类   get和set方法就不粘了
@Entity
@Table(name = "erp_order", schema = "")
@SuppressWarnings("serial")
public class ErpOrderEntity implements java.io.Serializable {
        /**主键*/
        private java.lang.String id;
        /**创建人名称*/
        private java.lang.String createName;
        /**创建人登录名称*/
        private java.lang.String createBy;
        /**创建日期*/
        private java.util.Date createDate;
        /**更新人名称*/
        private java.lang.String updateName;
        /**更新人登录名称*/
        private java.lang.String updateBy;
        /**更新日期*/
        private java.util.Date updateDate;
        /**商品信息id*/
    @Excel(name="商品信息id",width=15)
        private java.lang.String goodsinfoId;
        /**数量*/
    @Excel(name="数量",width=15)
        private java.lang.Integer orderNum;
        /**单价*/
    @Excel(name="单价",width=15)
        private java.lang.Double orderPrice;
        /**订单时间*/
    @Excel(name="订单时间",width=15,format = "yyyy-MM-dd")
        private java.util.Date orderTime;
        /**要求发货时间*/
    @Excel(name="要求发货时间",width=15,format = "yyyy-MM-dd")
        private java.util.Date orderNeedtime;
       

admin 发表于 2018-1-24 18:10:55

导入的excel上传下
页: [1]
查看完整版本: 导入出错