导出excel到本地



//根据登录名查询,显示其权限下的编码号
String s_pageno = request.getParameter("pageno");
String s_rowsize = request.getParameter("rowsize");
String orderby = request.getParameter("orderby");
String ordertype = request.getParameter("ordertype");
boolean isReserve = false;
if (ordertype != null && ordertype.equalsIgnoreCase("down")) {
isReserve = true;
}
int pageno = 0;
int rowsize = 0;
if (s_pageno != null && s_pageno.length() > 0) {
pageno = Integer.parseInt(s_pageno);
}
if (s_rowsize != null && s_rowsize.length() > 0) {
rowsize = Integer.parseInt(s_rowsize);
}

String saleTypeTemp = request.getParameter("saleTypeTemp");
String dlrTypeNum = request.getParameter("dlrTypeNum");
String dlrInfoRadioType = request.getParameter("dlrInfoRadioType");
String dlrInfoValue1 = request.getParameter("dlrInfoValue");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");


String radio = request.getParameter("radio");

saleTypeTemp = URLDecoder.decode(saleTypeTemp, "utf-8");
dlrTypeNum = URLDecoder.decode(dlrTypeNum, "utf-8");
dlrInfoValue1 = URLDecoder.decode(dlrInfoValue1, "utf-8");
System.out.println("div隐藏"+saleTypeTemp+",上面类型"+dlrTypeNum+",下面类型"+dlrInfoRadioType+",下面值"+dlrInfoValue1+",日期或经销店"+radio);
String dlrInfoValue = "";
int flagDlrType = 0;
if(dlrInfoRadioType!=null){ //经销店基本信息类型
flagDlrType = Integer.parseInt(dlrInfoRadioType);
}
if(dlrInfoValue1!=null&&dlrInfoValue1.length()>0){

String ssdf [] = dlrInfoValue1.split(",");

for(int i=0;i<ssdf.length;i++){
dlrInfoValue += "'"+ssdf[i]+"',";
}
dlrInfoValue = dlrInfoValue.substring(0, dlrInfoValue.length()-1);
}


HQLInfo hqlInfoBaseInfo = new HQLInfo();

switch(flagDlrType){
case 1:            //表示经销店名称

hqlInfoBaseInfo.setWhereBlock("dlrName in ("+dlrInfoValue+")");
break;              
case 2:  // 批次  

hqlInfoBaseInfo.setWhereBlock("phase in ("+dlrInfoValue+")");
break;             
case 3: //  FPD 

hqlInfoBaseInfo.setWhereBlock("fpd in ("+dlrInfoValue+")");

break;              

case 4://  区域


hqlInfoBaseInfo.setWhereBlock("region in ("+dlrInfoValue+")");


break;                
case 5: // 规模
hqlInfoBaseInfo.setWhereBlock("scale in ("+dlrInfoValue+")");
break;              
case 6:  //省份  
hqlInfoBaseInfo.setWhereBlock("dlrPro in ("+dlrInfoValue+")");
break;             
case 7:  // 城市 
hqlInfoBaseInfo.setWhereBlock("dlrCity in ("+dlrInfoValue+")");
break;              
case 8:   //  集团
hqlInfoBaseInfo.setWhereBlock("dlrGroup in ("+dlrInfoValue+")");
break;              
case 9: //  担当 foc 
hqlInfoBaseInfo.setWhereBlock("foc in ("+dlrInfoValue+")");
break;               
case 10: // 开业时间

hqlInfoBaseInfo.setWhereBlock("openDate in ("+dlrInfoValue+")");
break;              

}

String dlrCodes = "";
if(getServiceImpBaseInfo(request).findList(hqlInfoBaseInfo)!=null&&getServiceImpBaseInfo(request).findList(hqlInfoBaseInfo).size()>0){
List<TbDlrBaseInfo> listBaseInfo = new ArrayList<TbDlrBaseInfo>();
listBaseInfo = getServiceImpBaseInfo(request).findList(hqlInfoBaseInfo);
for(int i=0;i<listBaseInfo.size();i++){
dlrCodes += "'"+listBaseInfo.get(i).getDlrCode()+"',";
}
dlrCodes = dlrCodes.substring(0, dlrCodes.length()-1);
System.out.println(dlrCodes);
}
//*******************
String path="";
try {
path = URLEncoder.encode("导出的excel文件.xls", "UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}


OutputStream os = response.getOutputStream();// 取得输出流
response.reset();// 清空输出流
response.setHeader("Content-disposition", "attachment; filename="
+ path);// 设定输出文件头
response.setContentType("application/msexcel");// 定义输出类型


List<stockExcel>  lists = new ArrayList<stockExcel>();
String sql = "select a.region,a.dlr_code,a.dlr_name,a.fpd,b.stock_type,b.stock_data,b.stock_date,b.dlr_attr from tb_dlr_base_info a ,tb_dlr_stock_kpi b where  a.dlr_code = b.dlr_code and a.dlr_code in("+dlrCodes+") and b.stock_type = "+dlrTypeNum+" and b.stock_date>= '"+startTime+"-01'and b.stock_date<='"+endTime+"-01' and b.dlr_attr = 1 ";


lists = getExcelData1(sql);
if (lists.size() > 0) {


writeExcel1(os,lists);// 调用生成excel文件bean
} else {
return null;
}
return  null;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值