直接上代码

解决方案 »

  1.   


    HSSFWorkbook work = getHssFworkbook(list);
    int num =work.getSheetAt(0).getLastRowNum()-work.getSheetAt(0).getFirstRowNum();
    System.out.println("总条数为"+num);
    // FileOutputStream fos = new FileOutputStream("c:/abc.xls");
    // work.write(fos);
    // fos.close();
    Date enddate =new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    System.out.println("数据条数:"+list.size());
    System.out.println("开始时间为:"+sdf.format(begindate));
    System.out.println("结束时间为:"+sdf.format(enddate));

    response.setCharacterEncoding("UTF-8");
    String contenttype = "appliction/vnd.ms-excel";
    response.setContentType(contenttype);
    response.setHeader("Content-Disposition", "attachment;filename="
    + new String(("z" + ".xls").getBytes("gb2312"), "ISO8859-1"));
    work.write(response.getOutputStream());
    // response.flushBuffer();
      

  2.   

    我看过本地的c:/abc.xls 是有数据的。
      

  3.   

    你下载 是 z.xls 这个文件从来哪里来的
      

  4.   

    这个只是一个导出的filename名字.
      

  5.   

     肯定是空白的 你的response是来自于 z.xls  你这个东西 都没有  下下来 肯定是白的  
      

  6.   

    你前面那个打印总条数的数值是对的么,
    还有work.write(response.getOutputStream()); 这里在JSP页面老版本POI好像有BUG问题。
      

  7.   

    work.write(response.getOutputStream());
    不是这一句?
    那个filename应该只是名字吧。
      

  8.   

    反正用POI3.5之类从磁盘读取再打印出去respone是不行的。