码迷,mamicode.com
首页 > 其他好文 > 详细

Form_Form Builder Export导出为Excel(案例)

时间:2015-01-13 11:53:12      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:

2014-01-09 Created By BaoXinjian

 

 

/* Formatted on 2015/1/13 11:04:15 (QP5 v5.115.810.9015) */
DECLARE
   --以上五个变量照搬即可
   URL                 VARCHAR2 (2000);
   DB_FILE             NUMBER;
   WEB_SERVER_PREFIX   VARCHAR2 (255);
   RES                 BOOLEAN;
   MIME_TYPE           VARCHAR2 (255);
   L_ORGANZIATION_ID   NUMBER;

   --定义一个包含主从关系数据的CURSOR
   CURSOR CSR (
      V_ORGANIZATION_ID   IN            NUMBER
   )
   IS
        SELECT   CST.COST_GROUP_CODE,
                 CST.COST_GROUP_DESCRIPTION,
                 CST.COST_GROUP_DISABLE_DATE,
                 CAP.CAPABILITY,
                 EQP.EQP_CAP_DESC DESCRIPTION,
                 CAP.ACTIVE
          FROM   CUX2_CST_COST_GROUP_ALL CST,
                 CUX2_CST_COST_GROUP_EQPS_ALL CAP,
                 CUX2_BOM_EQP_CAP_TYPE EQP
         WHERE       CAP.COST_GROUP_ID(+) = CST.COST_GROUP_ID
                 AND EQP.EQP_CAP_CODE(+) = CAP.CAPABILITY
                 AND EQP.ORGANIZATION_ID(+) = CAP.ORGANIZATION_ID
                 AND CAP.ORGANIZATION_ID(+) = CST.ORGANIZATION_ID
                 AND CST.ORGANIZATION_ID = V_ORGANIZATION_ID
      ORDER BY   CST.ORGANIZATION_ID, CST.COST_GROUP_CODE, CAP.CAPABILITY;
BEGIN
   --获取Organzition_id
   L_ORGANZIATION_ID := FND_PROFILE.VALUE (MFG_ORGANIZATION_ID);
   --更改鼠标式样:漏斗鼠标(忙状态)
   SET_APPLICATION_PROPERTY (CURSOR_STYLE, BUSY);
   --显示进度条窗口,并设置进度为0
   APP_WINDOW.PROGRESS (0);
   --创建数据包,并设置文件头类型。
   DB_FILE :=
      FND_GFM.FILE_CREATE (CONTENT_TYPE   => text/html,
                           PROGRAM_NAME   => export);
   --输出题头行 注:chr(9) 为 tab键
   FND_GFM.FILE_WRITE_LINE (
      DB_FILE,
         Cost Group Code
      || CHR (9)
      || Cost Group Description
      || CHR (9)
      || Cost Group Disable Date
      || CHR (9)
      || Capability
      || CHR (9)
      || Description
      || CHR (9)
      || Active
   );

   --循环数据行
   FOR R IN CSR (L_ORGANZIATION_ID)
   LOOP
      FND_GFM.FILE_WRITE_LINE (
         DB_FILE,
            R.COST_GROUP_CODE
         || CHR (9)
         || R.COST_GROUP_DESCRIPTION
         || CHR (9)
         || TO_CHAR (R.COST_GROUP_DISABLE_DATE, YYYY-MM-DD HH24:MI:SS)
         || CHR (9)
         || R.CAPABILITY
         || CHR (9)
         || R.DESCRIPTION
         || CHR (9)
         || R.ACTIVE
      );
   END LOOP;

   --关闭数据包
   DB_FILE := FND_GFM.FILE_CLOSE (DB_FILE);
   --将数据包提交给客户端
   URL := FND_GFM.CONSTRUCT_DOWNLOAD_URL (WEB_SERVER_PREFIX, DB_FILE, TRUE);
   --DBMS_OUTPUT.PUT_LINE(URL);
   --打开URL地址下载
   FND_UTILITIES.OPEN_URL (URL);
   --更改鼠标式样:默认指针(常规状态)
   SET_APPLICATION_PROPERTY (CURSOR_STYLE, DEFAULT);
   APP_WINDOW.PROGRESS (1);            --显示进度条窗口,并设置进度为1(100%)
END;

 

 

 

 

 

Thanks and Regards

参考:kawontony - http://blog.itpub.net/24627116/viewspace-754506/

参考:kawontony - http://blog.itpub.net/24627116/viewspace-754513/

Form_Form Builder Export导出为Excel(案例)

标签:

原文地址:http://www.cnblogs.com/eastsea/p/4220635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!