永发信息网

java导出excel的问题, 我在本机上面测试的没有问题。在服务器上有问题

答案:4  悬赏:50  手机版
解决时间 2021-01-31 07:54
Unexpected Exception caught setting 'pageNum1' on 'class com.asiainfo.crm.sms.action.SmsInterfaceAction: Error setting expression 'pageNum1' with value '[Ljava.lang.String;@15d023f2'
2011-01-17 21:20:21,012 ERROR (com.opensymphony.xwork2.interceptor.ParametersInterceptor:242) - ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'pageNum2' on 'class com.asiainfo.crm.sms.action.SmsInterfaceAction: Error setting expression 'pageNum2' with value '[Ljava.lang.String;@13e7f00e'
最佳答案
把这个Exception捕捉一下,当出现异常的时候,打印一下将要被赋的值,看看是什么情况,它才会出现这个异常。
全部回答
遇到类似问题 关注
没办法,运行内存低、机子能开虚拟内存的话可以试试。。
java导出excel java代码packagecom.axon.fable.sams.view.action;importjava.io.ioexception;importjava.io.outputstream;importjava.util.list;importjavax.serv... java导出excel例举方式 方法一:导出excel数据的插件jexcelapi 程序实例如下: publicvoidexportclassroom(outputstreamos)throwspaikeexception{ try{ writableworkbookwbook=workbook.createworkbook(os);//建立excel文件 writablesheetwsheet=wbook.createsheet("教室信息表",0);//工作表名称 //设置excel字体 writablefontwfont=newwritablefont(writablefont.arial,16, writablefont.bold,false, jxl.format.underlinestyle.no_underline, jxl.format.colour.black); writablecellformattitleformat=newwritablecellformat(wfont); string[]title={"教室名","容量","类型","其他说明"}; //设置excel表头 for(inti=0;i<title.length;i++){ labelexceltitle=newlabel(i,0,title[i],titleformat); wsheet.addcell(exceltitle); } intc=1;//用于循环时excel的行号 classroomservicecs=newclassroomservice(); listlist=cs.findallclassroom();//这个是从数据库中取得要导出的数据 iteratorit=list.iterator(); while(it.hasnext()){ classroomdtocrdto=(classroomdto)it.next(); labelcontent1=newlabel(0,c,crdto.getroomname()); labelcontent2=newlabel(1,c,crdto.getcapicity().tostring()); labelcontent3=newlabel(2,c,crdto.getroomtypeid() .tostring()); labelcontent4=newlabel(3,c,crdto.getremark()); wsheet.addcell(content1); wsheet.addcell(content2); wsheet.addcell(content3); wsheet.addcell(content4); c++; } wbook.write();//写入文件 wbook.close(); os.close(); }catch(exceptione){ thrownewpaikeexception("导出文件出错"); } } 方法二:直接用java代码实现导出excel报表 packagecom.axon.fable.sams.view.action; importjava.io.ioexception; importjava.io.outputstream; importjava.util.list; importjavax.servlet.http.httpservletrequest; importjavax.servlet.http.httpservletresponse; importjxl.workbook; importjxl.write.writeexception; importjxl.write.biff.rowsexceededexception; importorg.apache.struts.action.actionform; importorg.apache.struts.action.actionforward; importorg.apache.struts.action.actionmapping; importorg.hibernate.hibernateexception; importorg.hibernate.query; importorg.hibernate.session; importorg.hibernate.transaction; importcom.axon.fable.empolderpackage.out.outjavascript; importcom.axon.fable.empolderpackage.page.pager; importcom.axon.fable.empolderpackage.string.mypublic; importcom.axon.fable.sams.common.baseaction; importcom.axon.fable.sams.exception.appbusinessexception; importcom.axon.fable.sams.exception.appsystemexception; publicclassstshipoperationactionextendsbaseaction{ privatestaticsessionsession=null; privatestatictransactionts=null; privatestaticqueryqueryc=null; privatestaticqueryqueryr=null; privatestaticqueryquery=null; privatestaticlistlist=null; privatestaticintegerstartrow; privatestaticintegerncurrentpage; privatestaticintegercell; privatestaticstringproperty; privatestaticstringsql; privatestaticstringtype; privatestaticstringcondition;//是否导出当前页 privatestaticstringcurrentpage; privatestaticstringfrom; privatestaticstringpactdata; privatestaticstringvoyagename; privatestaticstringvoyageno; privatestaticstringdwt; privatestaticstringhirefrom; privatestaticstringdeliveryposion; privatestaticstringredeliveryposion; privatestaticstringsheepowner; privatestaticstringaddr; privatestaticstringaddcomm; privatestaticstringrent; privatestaticstringfilename; privatestaticoutputstreamos; @override publicactionforwardfindall(actionmappingmapping,actionformform,httpservletrequestrequest,httpservletresponseresponse){ //todoauto-generatedmethodstub returnnull; } @override publicactionforwardfindbyid(actionmappingmapping,actionformform,httpservletrequestrequest,httpservletresponseresponse){ //todoauto-generatedmethodstub returnnull; } @override publicactionforwardsave(actionmappingmapping,actionformform,httpservletrequestrequest,httpservletresponseresponse){ //todoauto-generatedmethodstub returnnull; } publicstaticstringstrnull(objectnullstr,stringnewstr,integercell){ if(nullstr==null||nullstr.equals("")){returnnewstr;}else{cell+=1;returnnullstr+"";} } publicstaticstringgetstr(stringstr,integercell){ if(str==null||str.trim().equals("")){return"";}else{cell+=1;return","+str;} } publicstaticstringgetexceltile(stringtitle){ if(title==null) return""; if(title.equals("modela.stsid")) return"编号"; if(title.equals("modelc.pactdata")) return"合同日期"; if(title.equals("modela.voyagename")) return"航名"; if(title.equals("modela.voyageno")) return"航次"; if(title.equals("modelc.dwt")) return"dwt"; if(title.equals("modelc.hirefrom")) return"受载期"; if(title.equals("modela.deliveryposion")) return"交船地点"; if(title.equals("modela.redeliveryposion")) return"还船地点"; if(title.equals("modelc.sheepowner")) return"联系人"; if(title.equals("modelc.addr")) return"经纪人拥金"; if(title.equals("modelc.addcomm")) return"addcomm"; if(title.equals("modelc.rent")) return"租金"; return""; } publicactionforwardexporvoyagesinfotoexcel(actionmappingmapping,actionformform, httpservletrequestrequest,httpservletresponseresponse){ list=null; startrow=0; ncurrentpage=1; cell=0; type=request.getparameter("type"); condition=request.getparameter("condition");//是否导出当前页 currentpage=request.getparameter("currentpage"); from=request.getparameter("from"); pactdata=request.getparameter("modelc.pactdata"); voyagename=request.getparameter("modela.voyagename"); voyageno=request.getparameter("modela.voyageno"); dwt=request.getparameter("modelc.dwt"); hirefrom=request.getparameter("modelc.hirefrom"); deliveryposion=request.getparameter("modela.deliveryposion"); redeliveryposion=request.getparameter("modela.redeliveryposion"); sheepowner=request.getparameter("modelc.sheepowner"); addr=request.getparameter("modelc.addr"); addcomm=request.getparameter("modelc.addcomm"); rent=request.getparameter("modelc.rent"); if(type!=null&&type.trim().equals("1")){ type="已还船舶--费用未结清"; }else{ type="已还船舶--费用已结清"; } property=getstr(pactdata,cell)+getstr(voyagename,cell)+getstr(voyageno,cell)+getstr(dwt,cell)+getstr(hirefrom,cell) +getstr(deliveryposion,cell)+getstr(redeliveryposion,cell)+getstr(sheepowner,cell)+getstr(addr,cell)+getstr(addcomm,cell) +getstr(rent,cell); property=property.substring(1); stringsplit[]=property.split(","); //system.out.println("-----------------------------property:"+property); if(currentpage!=null&&!currentpage.trim().equals("")){ ncurrentpage=integer.parseint(currentpage); }else{ outjavascript.outstring(response,"sorry!failedtogetinformationofpager."); returnnull; } try{ session=getservicelocator().getbasehibernatedao().getsession(); sql="selectcount(*)"+from; query=session.createquery(sql); list=query.list(); for(inti=0;i<list.size();i++){ totalsize=(integer)list.get(i); if(totalsize!=0){ pager=newpager(ncurrentpage,totalsize); } } query=getservicelocator().getbasehibernatedao().getsession().createquery("select"+property+from); if(condition!=null&&condition.trim().equals("1")){//分页数据 startrow=(ncurrentpage-1)*pager.getpagesize(); query.setfirstresult(startrow); query.setmaxresults(pager.getpagesize()); //system.out.println("---------------------------------------------------query:"+query); } list=query.list(); filename="shipinfo"; os=response.getoutputstream(); response.reset(); response.setheader("content-disposition", "attachment;filename="+filename+".xls"); response.setcontenttype("application/msexcel"); jxl.write.writableworkbookwbook=workbook.createworkbook(os); jxl.write.writablesheetwsheet=wbook.createsheet("thefirstsheet",0); for(inti=0;i<split.length;i++){ jxl.write.labelwlabel0; wlabel0=newjxl.write.label(i,0,getexceltile(split[i])); wsheet.addcell(wlabel0); } jxl.write.labelwlabel1; for(inti=0;i<list.size();i++){ if(split.length==1){ objectstrval=(object)list.get(i); stringjavascript=""+mypublic.tohtmlstr(strval==null?"":strval.tostring().trim())+""; wlabel1=newjxl.write.label(0,i+1,strval==null?"":strval.tostring().trim()); wsheet.addcell(wlabel1); }else{ object[]strval=(object[])list.get(i); for(intj=0;j<strval.length;j++){ stringjavascript=""+mypublic.tohtmlstr(strval[j]==null?"":strval[j].tostring().trim())+""; //system.out.println("===================script:"+javascript); wlabel1=newjxl.write.label(j,i+1,strval[j]==null?"":strval[j].tostring().trim()); wsheet.addcell(wlabel1); } } } wbook.write(); response.flushbuffer(); wbook.close(); os.close(); }catch(ioexceptione){ //todoauto-generatedcatchblock outjavascript.outstring(response,"sorry!exportexcelexception."); e.printstacktrace(); }catch(hibernateexceptione1){ //todoauto-generatedcatchblock outjavascript.outstring(response,"sorry!databaseexception."); e1.printstacktrace(); }catch(appsystemexceptione1){ //todoauto-generatedcatchblock outjavascript.outstring(response,"sorry!systemexception."); e1.printstacktrace(); }catch(appbusinessexceptione1){ //todoauto-generatedcatchblock outjavascript.outstring(response,"sorry!databaseexception."); e1.printstacktrace(); }catch(rowsexceededexceptione){ //todoauto-generatedcatchblock outjavascript.outstring(response,"sorry!exportexcelexception."); e.printstacktrace(); }catch(writeexceptione){ //todoauto-generatedcatchblock outjavascript.outstring(response,"sorry!exportexcelexception."); e.printstacktrace(); } returnnull; } @override publicactionforwardupdate(actionmappingmapping,actionformform,httpservletrequestrequest,httpservletresponseresponse){ //todoauto-generatedmethodstub returnnull; } } 还有其他很多种字数限制无法一一举例方式
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
淘宝上买的手机可以去实体店维修吗
刘谦化水为冰魔术是怎么回事?(周日我最大里
了解巴以冲突,写小论文《我看巴以战争》
时尚指艺地址好找么,我有些事要过去
我国预算法规定的预算支出中的主要的部分是(
绍兴柯桥哪有给小儿做康复的
同羣的意思是什么啊?知道的请说下!
龙之谷手动更新
诗美诗格6+1化妆品养生馆(金山店)地址在哪,
卷扬机起升高度15m,钢丝绳长度17m行不行?
最新版本的手机UC浏览器启动打开未关闭窗口的
灯笼谜语哥哥有弟弟无
愎很的意思是什么啊?知道的请说下!
豌豆种皮灰色对白色为显性,具有相对性状的纯
有没有这样的一个软件,拍照英语单词,教人读
推荐资讯
一个银行在不同国家的分行的汇率相同吗?
【坊的拼音】坊有哪些读音求组词越多越好
重庆市工商局地址在哪,我要去那里办事
玉糁羹的意思是什么啊?知道的请说下!
1436是什么银行卡帐号开头
带企的成语有哪些
双眼皮埋线抽脂好像太宽了.现在看着特别丑.大
大连良运传琦温泉酒店怎么去啊,我要去那办事
【vgr】vgr220一瓶有多少颗。
匪棍的意思是什么啊?知道的请说下!
请问哪种机头逆变器电鱼比较好?
盐城福利彩票合德镇朝阳街40号分点地址在哪,
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?