예제 #1
0
 /** 导出EXCELL */
 public void exportFtpFile() {
   response.setContentType("application/vnd.ms-excel; charset=GBK");
   OutputStream fOut = null;
   try {
     fOut = response.getOutputStream();
     StringBuffer cvs = ftpFileService.export(getParams());
     byte[] buffer = cvs.toString().getBytes("GBK");
     response.reset();
     response.addHeader(
         "Content-Disposition",
         "attachment;filename="
             + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())
             + ".csv");
     response.addHeader("Content-Length", "" + buffer.length);
     response.setHeader("Content-Type", "application/vnd.ms-excel");
     response.setContentType("application/ms-excel");
     response.getOutputStream().write(buffer);
     response.getOutputStream().close();
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     try {
       fOut.flush();
       fOut.close();
     } catch (Exception e) {
     }
   }
 }