将 excel 导出到指定的路径 play!

/**
     * 导出验证用户的操作日志的表格
     *
     * @throws Exception
     */
    public static void exportWeChatUserLogs(String searchCriteria) {
        // 根据需求生成excel表格
        HSSFWorkbook wb = createHSSFWorkbook(searchCriteria);

        Date dt = new Date();// 如果不需要格式,可直接用dt,dt就是当前系统时间
        DateFormat df = new SimpleDateFormat(Const.TIME_FORMATE);// 设置显示格式
        String nowTime = "";
        nowTime = df.format(dt);
        // 设置默认的保存文件的文件名:当前时间戳.xls格式
        String filename = nowTime + Const.EXCEL_FORMATE;
        // 这里存放的是指定的目录data(一般是从配置文件中读取)
        String filePath = Play.applicationPath + Const.FILE_EXCEL_PATH;
        File dirFile = new File(filePath);
        if (!dirFile.exists()) {
            dirFile.mkdirs();
        }
        try {
            // 输出文件流
            FileOutputStream fout = new FileOutputStream(filePath + "/" + filename);
            wb.write(fout);
            fout.flush();
            fout.close();
            // 保存到指定文件夹的文件中
            File file = new File(filePath + "/" + filename);
            // 返回文件,让用户下载
            renderBinary(file);
        } catch (Exception e) {
            e.printStackTrace();
            // 返回操作失败,请重新操作的提示语
            // 出错时,直接跳到微信用户操作日志展示的页面
            flash.put(Const.MSG_ERROR, Messages.get("export_excel_fail"));
            weChatUserStatisticalLogs(0, searchCriteria);
        }
    }