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'
java导出excel的问题, 我在本机上面测试的没有问题。在服务器上有问题
答案:4 悬赏:50 手机版
解决时间 2021-01-31 07:54
- 提问者网友:那叫心脏的地方装的都是你
- 2021-01-30 09:16
最佳答案
- 五星知识达人网友:想偏头吻你
- 2021-01-30 10:31
把这个Exception捕捉一下,当出现异常的时候,打印一下将要被赋的值,看看是什么情况,它才会出现这个异常。
全部回答
- 1楼网友:北方的南先生
- 2021-01-30 12:53
遇到类似问题 关注
- 2楼网友:醉吻情书
- 2021-01-30 11:21
没办法,运行内存低、机子能开虚拟内存的话可以试试。。
- 3楼网友:雾月
- 2021-01-30 10:52
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;
}
}
还有其他很多种字数限制无法一一举例方式
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯