请问:
HSSFWorkbook createdfillcard = new HSSFWorkbook();
--这里在写excel文件----
      httpServletResponse.setContentType("Application/msexcel");
      httpServletResponse.setHeader("Content-disposition","attachment;filename=book.xls" );
      return (actionMapping.findForward("success"));我想直接返回一个excel文件下载,页面无需任何改动,但是结果返回的是success那个页面的excel格式的文件了,请问如果直接返回一个文件供下载,谢谢

解决方案 »

  1.   

    public byte[] writeXLS() throws IOException {
            ByteArrayOutputStream fileOut = null;
            byte[] bytes = null;
            try {
                fileOut = new ByteArrayOutputStream();
                excel.write(fileOut);
                bytes = fileOut.toByteArray();
            } catch (IOException e) {
                bytes = null;
            } finally {
                if (fileOut != null) {
                    fileOut.close();
                }
            }
            return bytes;
        }给你个这样的方法
    然后在显示的地方把这个字节流得到
    然后用response输出,类型选Application/msexcel
      

  2.   

    up,success页面要把楼上的字节流用response输出出来。