问题描述
WEB页面数据导出excel为空白的,后台代码跑的能导出数据,这和方法没关系的吧,会不会是主机流量问题。publicvoidtoExcel(HttpServletRequestrequest,HttpServletResponseresponse)/**/throwsException/**/{/*206*/longpk=Long.parseLong(request.getParameter("pk"));/*207*/DBGridInterfacegrid=DBGridInterfaceManager.findDBGridInterface(pk);/**//*210*/if(grid==null){/*211*/StringexcelOutputPK=request.getParameter("excelOutputPK");/*212*/if((excelOutputPK!=null)&&(StringUtils.isNumeric(excelOutputPK))){/*213*/grid=DBGridInterfaceManager.findDBGridInterfaceForExcelOutput(Long.parseLong(excelOutputPK));/**/}/**/}/**//*217*/if(grid==null){/*218*/response.setContentType("text/html;charset=GBK");/*219*/Writerwriter=response.getWriter();/**//*221*/Stringmsg=AppframeLocaleFactory.getResource("com.ai.appframe2.web.tag.miss_table_obj");/*222*/writer.write(msg);/*223*/return;/**/}/**//*226*/Stringfilename=HttpUtil.getAsString(request,"filename");/**//*228*/inteachCount=HttpUtil.getAsInt(request,"eachCount");/**//*231*/StringpageIndex_str=HttpUtil.getAsString(request,"pageIndex");/*232*/intpageIndex=-1;/*233*/if((pageIndex_str!=null)&&(!pageIndex_str.equals(""))){/**/try{/*235*/pageIndex=Integer.parseInt(pageIndex_str);/**/}/**/catch(Exceptione)/**/{/**/}/**/}/**//*242*/String[]titles=HttpUtil.getAsString(request,"columnTitle").split(";");/*243*/HashMaptitle_map=newHashMap();/*244*/for(inti=0;i<titles.length;i++){/*245*/if(!titles[i].equals("")){/*246*/intindex=titles[i].indexOf("=");/*247*/if(index==-1)/**/continue;/*249*/StringcolumnName=titles[i].substring(0,index);/*250*/StringcolumnTitle=titles[i].substring(index+1,titles[i].length());/*251*/title_map.put(columnName,columnTitle);/**/}/**//**/}/**//*256*/booleanuserZipFormat=false;/*257*/StringstrUseZipFormat=HttpUtil.getAsString(request,"userZipFormat");/*258*/if("true".equalsIgnoreCase(strUseZipFormat)==true){/*259*/userZipFormat=true;/**/}/**//*265*/ServletOutputStreamaOutputStream=response.getOutputStream();/**//*267*/StringtableData=HttpUtil.getAsString(request,"tabledata");/*268*/StringcolumnNameStr=HttpUtil.getAsString(request,"columnNameStr");/*269*/String[]columnNames=null;/*270*/if((columnNameStr!=null)&&(!"".equals(columnNameStr))){/*271*/columnNames=columnNameStr.split(";");/**/}/**//*274*/if(userZipFormat==true){/*275*/response.setContentType("application/x-download");/*276*/response.addHeader("Content-Disposition","attachment;filename="+encode(filename,"utf-8")+".zip");/**//*278*/ZipOutputStreamzipOutputStream=newZipOutputStream(aOutputStream);/*279*/ZipEntryentry=newZipEntry(encode(filename,"utf-8")+".csv");/*280*/zipOutputStream.putNextEntry(entry);/*281*/grid.toExcel(zipOutputStream,pageIndex,title_map,eachCount);/**//*283*/zipOutputStream.flush();/*284*/zipOutputStream.close();/**/}/**/else/**/{/*288*/response.setContentType("application/ms-excel");/*289*/response.addHeader("Content-Disposition","attachment;filename="+encode(filename,"utf-8")+".csv");/*290*/if((columnNameStr!=null)&&(!"".equals(columnNameStr))){/*291*/grid.toExcel(aOutputStream,pageIndex,title_map,eachCount,columnNames);/**/}/*294*/elseif((tableData==null)||("".equals(tableData))){/*295*/grid.toExcel(aOutputStream,pageIndex,title_map,eachCount);/**/}/**/else{/*298*/grid.toExcel(aOutputStream,pageIndex,title_map,eachCount,tableData);/**/}/**//**/}/**//*303*/aOutputStream.flush();/*304*/aOutputStream.close();/**/}
解决方案
解决方案二:
你导出一条测试看看呢
解决方案三:
导2W以下是没有问题的。
解决方案四:
你的后台报不报错啊,VM是不是超出了,分多个文件流输出
解决方案五:
与excel版本有关