zoukankan      html  css  js  c++  java
  • 导出Excel表格

    @RequestMapping("/exportList.do")
    @ResponseBody
    public void exportList(HttpServletRequest request, HttpServletResponse response) {
    Map<String, String> map = RequestUtil.getParameterMap(request);

    List<BdcYwsqEntity> ywsqs = djdyService.queryDyaList(map);
    try{
    HSSFWorkbook wb = new HSSFWorkbook();
    //建立新的sheet对象(excel的表单)
    HSSFSheet sheet=wb.createSheet("抵押不动产信息");
    HSSFRow row1=sheet.createRow(0);

    row1.createCell(0).setCellValue("状态");
    row1.createCell(1).setCellValue("业务号");
    row1.createCell(2).setCellValue("行政区划");
    row1.createCell(3).setCellValue("时间");
    row1.createCell(4).setCellValue("类型");
    row1.createCell(5).setCellValue("名称");
    row1.createCell(6).setCellValue("名称");
    row1.createCell(7).setCellValue("名称");
    row1.createCell(8).setCellValue("类型");
    row1.createCell(9).setCellValue("合同号");
    row1.createCell(10).setCellValue("类型");
    row1.createCell(11).setCellValue("单元号");
    row1.createCell(12).setCellValue("");
    row1.createCell(13).setCellValue("");
    row1.createCell(14).setCellValue("");
    row1.createCell(15).setCellValue("证号");
    row1.createCell(16).setCellValue("方式");
    row1.createCell(17).setCellValue("金额");
    row1.createCell(18).setCellValue("时间");
    row1.createCell(19).setCellValue("日期");
    row1.createCell(20).setCellValue("缴费状态");
    for(int i=1;i<=ywsqs.size();i++){
    HSSFRow row2 =sheet.createRow(i);
    String propertyAsString = "ztName,bsn_pts_no,qxName,sqsj,djlxName,dyqrName,dyrName,zwrName,qllxName,hth,bdclxName,fwbdcdyh,fwzl,mj,fwyt,ybdczh,dyfsName,zgzqse,zwlxqssj,zwlxjssj,jfztName";

    row2.createCell(0).setCellValue(ywsqs.get(i-1).getZtName());
    row2.createCell(1).setCellValue(ywsqs.get(i-1).getBsn_pts_no());
    row2.createCell(2).setCellValue(ywsqs.get(i-1).getQxName());
    if(ywsqs.get(i-1).getSqsj()==null){
    row2.createCell(3).setCellValue("");
    }else{
    row2.createCell(3).setCellValue(ywsqs.get(i-1).getSqsj());
    }
    row2.createCell(4).setCellValue(ywsqs.get(i-1).getDjlxName());
    row2.createCell(5).setCellValue(ywsqs.get(i-1).getDyqrName());
    row2.createCell(6).setCellValue(ywsqs.get(i-1).getDyrName());
    row2.createCell(7).setCellValue(ywsqs.get(i-1).getZwrName());
    row2.createCell(8).setCellValue(ywsqs.get(i-1).getQllxName());
    row2.createCell(9).setCellValue(ywsqs.get(i-1).getHth());
    row2.createCell(10).setCellValue(ywsqs.get(i-1).getBdclxName());
    row2.createCell(11).setCellValue(ywsqs.get(i-1).getFwbdcdyh());
    row2.createCell(12).setCellValue(ywsqs.get(i-1).getFwzl());
    row2.createCell(13).setCellValue(ywsqs.get(i-1).getMj().toString());
    row2.createCell(14).setCellValue(ywsqs.get(i-1).getFwyt());
    row2.createCell(15).setCellValue(ywsqs.get(i-1).getYbdczh());
    row2.createCell(16).setCellValue(ywsqs.get(i-1).getDyfsName());
    if(ywsqs.get(i-1).getZgzqse()==null){
    row2.createCell(17).setCellValue("");
    }else{
    row2.createCell(17).setCellValue(ywsqs.get(i-1).getZgzqse().toString());
    }
    if(ywsqs.get(i-1).getZwlxqssj()==null){
    row2.createCell(18).setCellValue("");
    }else{
    row2.createCell(18).setCellValue(ywsqs.get(i-1).getZwlxqssj());
    }
    if(ywsqs.get(i-1).getZwlxjssj()==null){
    row2.createCell(19).setCellValue("");
    }else{
    row2.createCell(19).setCellValue(ywsqs.get(i-1).getZwlxjssj());
    }

    row2.createCell(20).setCellValue(ywsqs.get(i-1).getJfztName());

    }
    response.setCharacterEncoding("utf-8");
    OutputStream output= response.getOutputStream();
    response.reset();
    response.setHeader("Content-disposition", "attachment; filename=details.xls");
    response.setContentType("application/vnd.ms-excel");
    wb.write(output);
    output.close();
    }catch (Exception e){
    e.printStackTrace();
    }

    }
  • 相关阅读:
    Chapter 2 Sockets and Patterns【选译,哈哈】 Part 2 Messags Partterns
    WPF动态更改Image控件图片路径
    Chapter 2 Sockets and Patterns【选译,哈哈】 Part 1
    Chapter 2 Sockets and Patterns【选译,哈哈】 Part 4 Handling Errors and ETERM
    Chapter 2 Sockets and Patterns【选译,哈哈】 Part 3 Messags Partterns
    Visual Studio 2008 测试项目无法正常显示解决办法
    Ext.NET控件介绍—Form控件
    ThoughtWorks(中国)程序员读书雷达
    Ext.net 中日期格式的计算
    Sql 分割 键值对字符串 得到某值对应的名称
  • 原文地址:https://www.cnblogs.com/qxqbk/p/11693598.html
Copyright © 2011-2022 走看看