response.setContentType("application/vnd.ms-excel; charset=GBK");        try
        {
            File ff = new File(ÄãµÄexcelÎļþ);
            response.setHeader("Content-Disposition", "attachment; filename=ÏúºÅ´¦Àí½á¹û.xls");            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(ff));
            byte[] buf = new byte[1024];
            ServletOutputStream out = response.getOutputStream();
            for (int readed = bis.read(buf); readed >= 0; readed = bis.read(buf))
                out.write(buf, 0, readed);            bis.close();
            out.flush();
            out.close();
            response.flushBuffer();
        }
        catch (Exception e)
        {
            log.debug("ÏÂÔØÎļþʱ³ö´í" + e.getMessage());
            return null;
        }

解决方案 »

  1.   

    response.setContentType("application/vnd.ms-excel; charset=GBK");        try
            {
                File ff = new File(ÄãµÄexcelÎļþ);
                response.setHeader("Content-Disposition", "attachment; filename=ÏúºÅ´¦Àí½á¹û.xls");            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(ff));
                byte[] buf = new byte[1024];
                ServletOutputStream out = response.getOutputStream();
                for (int readed = bis.read(buf); readed >= 0; readed = bis.read(buf))
                    out.write(buf, 0, readed);            bis.close();
                out.flush();
                out.close();
                response.flushBuffer();
            }
            catch (Exception e)
            {
                log.debug("down file is error" + e.getMessage());
                return null;
            }
      

  2.   

    File ff = new File(ÄãµÄexcelÎļþ);
    response.setHeader("Content-Disposition", "attachment; filename=ϺŴ¦Àí½á¹û.xls");
    那些:(ÄãµÄexcelÎļ&thorn)和=ϺŴ¦Àí½á¹û.xls");是干什么的?
      

  3.   

    可是结果是页面在EXCEL中显示啊 ?
      

  4.   

    EXCEL嵌入WEB页面
    是模拟嵌入还是真实嵌入啊?
      

  5.   

    File ff = new File(ÄãµÄexcelÎļþ);
    response.setHeader("Content-Disposition", "attachment; filename=ϺŴ¦Àí½á¹û.xls");
    那些:(ÄãµÄexcelÎļ&thorn)和=ϺŴ¦Àí½á¹û.xls");是干什么的?
    这些应当是要传文件的参数。