java.lang.Exception: java.lang.IllegalArgumentException: firstMovedIndex, lastMo

       这两天系统在导出Excel(2003的版本,代码中的引用的API也是针对03版的Excle)数据时,老是报java.lang.Exception: java.lang.IllegalArgumentException: firstMovedIndex, lastMovedIndex out of order 错误,导致无法正常导出Excel。网上查了一下,大部分都是说POI的版本问题,需要用POI 3.9的jar包。 经过昨晚的熬夜核查,发现修改一下方法即可以正常导出。


源代码:
HSSFSheet ws = wb.getSheetAt(i);
ws.shiftRows(j+dataStartRow, ws.getPhysicalNumberOfRows(), 1, true, false);


修改shiftRows方法中的参数:
HSSFSheet ws = wb.getSheetAt(i);
ws.shiftRows(j+dataStartRow, ws.getLastRowNum(), 1, true, false);


即将ws.getPhysicalNumberOfRows()替换为 ws.getLastRowNum()。




控制台原抛出的异常如下:

DEBUG - accept:image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/QVOD, application/QVOD, application/x-ms-application, application/x-ms-xbap, applicacookie:JSESSIONID=6127F149506B190A49849E7A1B19DF17; COOKIE_TOKEN_KEY=%2Bvn7EYVidpGMPvEx8AoxjyDKP3RevgA4Q7AWFOsfPr1Wjfr%2BL3kwKwFdjygoU5%2BNunJ3zszCHahJ0kskpKb%2B9g%3D%3DPath.2)
reportGroupBeanVo.reportGroupId:??????406
DEBUG - java.lang.Exception: java.lang.IllegalArgumentException: firstMovedIndex, lastMovedIndex out of order
        at com.eshore.common.web.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:95)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
        at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
        at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
        at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.eshore.ssoclient.web.ModcompsFilter.doFilter(ModcompsFilter.java:101)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.eshore.ssoclient.web.SSOFilter.doFilter(SSOFilter.java:295)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.eshore.ssoclient.web.OASSOFilter.doFilter(OASSOFilter.java:184)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: firstMovedIndex, lastMovedIndex out of order
        at org.apache.poi.ss.formula.FormulaShifter.<init>(FormulaShifter.java:56)
        at org.apache.poi.ss.formula.FormulaShifter.createForRowShift(FormulaShifter.java:81)
        at org.apache.poi.hssf.usermodel.HSSFSheet.shiftRows(HSSFSheet.java:1411)
        at org.apache.poi.hssf.usermodel.HSSFSheet.shiftRows(HSSFSheet.java:1262)
        at com.eshore.ppm.action.imusic.ReportGroupAction.reportExport(ReportGroupAction.java:258)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
        at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
        at org.apache.struts2.interceptor.de
DEBUG - Executing prepared SQL update










                                      @xuyanxilu.pudongqu.shanghai 2014-07-02 12:55

你可能感兴趣的:(java.lang.Exception: java.lang.IllegalArgumentException: firstMovedIndex, lastMo)