APEX

Excel Merge and Download using Custom Template in APEX

For Merging cells in Excel and for other CSS in download property, i.e  to create  down loadable XLS formatted sheets from any version of APEX use the following steps: 1. Create a new blank page in the application using Customized template. In that customized template remove all the contents in the page, like navigation menus, APEX page Toolbar, and others , since by putting this in a Before Header process on a page, the entire page will be downloaded as a native Excel Spreadsheet. 2. Create PLSQL Region with no template. — Should use recursion for a full tree, but we only need executives.  DECLARE    l_dirtotal   NUMBER (12, 2); BEGIN    HTP.p       (‘<table border=1 white-space=nowrap><tr style=”background-color:silver;”>     <th colspan=5>Employee</th><th>Title</th><th>Salary</th>     <th>Direct Report Total</th></tr>’       );    FOR c_exec IN (SELECT *                     FROM employee                    WHERE direct_report_id IS NULL)    LOOP       SELECT SUM (salary)         INTO l_dirtotal         FROM employee        WHERE direct_report_id = c_exec.ID;       HTP.p          (   ‘<tr height=80><th align=right><img src=”‘           || c_exec.image           || ‘”></th><th colspan=4 style=”white-space:nowrap;font-size:36px;color:green;background-color:#CCFFCC;”>’           || c_exec.NAME           || ‘</th><th>’           || c_exec.title           || ‘</th>     <th style=”font-size:36px;”>’…

Read More

Get Filtered Columns and Values in APEX Interactive Report

In order to get the filtered columns and their corresponding values in APEX Interactive Report, we can use this code.  So if the user selects multiple filters in IR and we need to retrieve the values of filter columns and their corresponding values, conditions, operators used for the conditions,etc we can retrieve using the below code: SELECT ircond.condition_name, ircond.condition_type, ircol.report_label,        ircond.condition_column_name, ircond.condition_operator,        ircond.condition_expr_type, ircond.condition_expression,        ircond.condition_expression2, ircond.condition_sql,        ircond.condition_display, ircond.condition_enabled   FROM apex_application_page_ir ir JOIN apex_application_page_ir_rpt irr        ON ir.interactive_report_id = irr.interactive_report_id        JOIN apex_application_page_ir_cond ircond        ON irr.report_id = ircond.report_id        JOIN apex_application_page_ir_col ircol        ON ir.interactive_report_id = ircol.interactive_report_id      AND ircond.condition_column_name = ircol.column_alias  WHERE ir.application_id = TO_NUMBER (:app_id)    AND ir.page_id = TO_NUMBER (:app_page_id)    AND ir.region_name = ‘Interactive Report’    AND ircond.condition_type = ‘Filter’    AND irr.session_id = :app_session    AND irr.base_report_id =           (SELECT apex_ir.get_last_viewed_report_id (TO_NUMBER (:app_page_id),                                                      ir.region_id                                                     )              FROM DUAL) Use a condition to identify the specific interactive report using either the region name or a static region ID.  Note: Can filter using Actions Menu and also using Header column filter.  Example: The below filtered columns and corresponding values can be retrieved using the above code.

Read More

Highlight Tabular Form Rows on addition from Pop-up

To Highlight Tabular Form Rows on addition from Pop-up: 1. Paste the following code in the dynamic action:          On Refresh of region        …

Read More

Set Interactive Report Filter with URL Parameters

Interactive Reports are very powerful, the end user can set filters, highlighting, add computed columns, do control breaks or groupings and much more. As a Developer you might sometimes have…

Read More

Progress Bar in Reports in APEX5

APEX can create “Percentage Bars” within a report. This can be achieved using HTML Code in your Report SQL Query. Steps: 1- Create your report: Create an Interactive or Classic Report using SQL query : SELECT CASE           WHEN COLUMN <= 30              THEN    ‘<div class=”a-Report-percentChart” style=”background-color:#000000;width:100%;”><div class=”a-Report-percentChart-fill” style=”width:’                   || COLUMN                   || ‘% ; background-color: 330099;”></div><span class=”u-VisuallyHidden”>’                   || COLUMN                   || ‘</span></div>’                   || COLUMN                   || ‘%’           WHEN COLUMN BETWEEN 30 AND 50              THEN    ‘<div class=”a-Report-percentChart” style=”background-color:#000000;width:100%;”><div class=”a-Report-percentChart-fill” style=”width:’                   || COLUMN                   || ‘% ; background-color:CC0000;”></div><span class=”u-VisuallyHidden”>’                   || COLUMN                   || ‘</span></div>’                   || COLUMN                   || ‘%’           WHEN COLUMN BETWEEN 55 AND 70              THEN    ‘<div class=”a-Report-percentChart” style=”background-color:#000000;width:100%;”><div class=”a-Report-percentChart-fill” style=”width:’                   || COLUMN                   || ‘% ; background-color:#99eb47;”></div><span class=”u-VisuallyHidden”>’                   || COLUMN                   || ‘</span></div>’                   || COLUMN                   || ‘%’        END AS “Progress bar”…

Read More

Displaying images in a Report

Purpose: This document shows user how to include images in report            By assumption we will upload a image to work space and call that particular image through HTML using image name and displays in classical or  interactive report. Another way is that, the user can able to retrieve images from the Database. Benefits: ØUser able to know prior information about subject ØFaster Turnaround. ØReport is used to get the information if user include an image.it will be more helpful. Steps to display images in report Step1: Create a new page Step 2: Create a region èreportèclassical or interactive reportèName for the reportèSQL queryè follow the  below query   Case and Decode both  methods can be done. Based on Requirement modify the query. Example:  CASE                   WHEN gender = ‘MALE’ AND emp_image IS NULL                      THEN  ‘<img src=”#WORKSPACE_IMAGES#not_found_male.jpg” width=”75px;” height=”75px;”/>‘   // uploaded default male icon in workspace and checking for the condition image is available in table or not.                   WHEN gender = ‘FEMALE’ AND emp_image IS NULL                      THEN  ‘<img src=”#WORKSPACE_IMAGES#not_found_female.jpg” width=”75px;” height=”75px;”/>’  // uploaded default Female icon in workspace ans checking for the condition image is available in table or not.                   WHEN emp_image IS NOT NULL  // if  the image already available in the database                      THEN     ‘<img alt=”‘       //HTML tag                            || apex_escape.html_attribute (c.first_name)  // this function returs name of the employee                           || ‘” title=”‘                           || apex_escape.html_attribute (c.first_name) …

Read More

Role based Authorization in Oracle APEX5

Objective: To implement Role based Authorization in Oracle APEX Application, in version 5. Application Item: USER_ROLE Table: ROLE_ACCESS_CONTROL The purpose of this table is to store the privileges on Regions, Buttons and Items, for each role. Page access is controlled through the Region access (Even if one Region in a Page is given access, its Page will appear; Components cannot be created without a “Region”;) Column Name Data Type Comments ROLE_ACCESS_ID NUMBER Primary Key USER_ROLE VARCHAR2(30) Role Name APP_ID NUMBER APEX System Variable PAGE_ID NUMBER APEX System Variable REGION_ID NUMBER APEX System Variable COMPONENT_ID VARCHAR2(30) APEX5 System Variable COMPONENT_NAME VARCHAR2(30) APEX5 System Variable…

Read More

Restrict Copy Paste & Right Click In Apex Page

PURPOSE: The Purpose of this component is to restrict the copy option from the user level of apex page. SCENARIO : 1.Consider in our apex application we are providing any confidential message or data that should not be copied by user level,we can restrict by this component. 2.If we want to provide any notification message for restrict the copy option for that particular confidential page, we can use this component. STEPS TO DO: 1.Create a page in apex and use the region to display some text that to restrict copy option 2.In that region source type the script that given below and save the page and run it. SCRIPT EXPLANATION: We can restrict the copy option by these ways, 1.Restrict Ctrl+C Button. 2.Restrict Mouse Right click . This script will restrict these two ways, //Restrict Ctrl+C Button in javascript <head> <script language=”javascript”> <!– function Disable_Control_C() { var keystroke = String.fromCharCode(event.keyCode).toLowerCase(); if (event.ctrlKey && keystroke == ‘c’) { event.returnValue = false; alert(‘You can not copy here’); } } </script> </head> //This script will restrict the CTRL+C and stop the action in user level <body onkeydown=”javascript:Disable_Control_C()”> </body>…

Read More

Creating Interactive Report as Excel format with applying font for particular column values

PURPOSE: If we want to show any report in excel format in page level with the different font of column values we can use this component script to achieve the scenario. Steps To Follow: Step 1 : Create a interactive report that we need to show in excel format Step 2 : In a report definition type the  query  base on the select list and dense_rank () method  Step 3: You can use the HTML tags in the select list to show the name in different format that we need Excel Format Interactive Report Standard SELECT (‘<b>’ || col1 || ‘<b>’) “xxx”,                 (‘<b>’ || col2 || ‘<b>’) “yyy”,                  (‘<u>’ || col3 || ‘<u>’) “yyy”,                 (‘<i>’ || col4 || ‘<i>’) “yyy”,. . .    FROM (SELECT DECODE (rk, 1, col1, ”) “xxx”,                DECODE (rk, 1, col2 || ‘%’, ”) “yyy”, col3, col4, col5,col6           FROM                 (SELECT col1, col2,                    Col3,col4,col5,col6                                                                          DENSE_RANK () OVER (PARTITION BY col6 ORDER BY tablename1.ROWID)                          rk                   FROM t1, t2                  WHERE t1.col1=t2.col1                    AND condition1                    AND condition2     AND condition3                    AND condition4 )); Step 3 :  Create a query based on this and modify the column name and enter the query in the report region Step 4 : After Entering the query go to Interactive report  à Report Attributes  change the Display Text As  à Standard Report Column  Step 5 : Now we can able to see the report in excel format  Coding Explanation…

Read More

Search Bar in Tabular Form

PURPOSE: The search button in tabular form is helpful to identify the exact data in the tabular form, that will act like a filter in interactive report  shows the particular values what we enter in that search field. Steps To Follow: Step 1: Create Text Field in the Label of Search with Search Button on above Tabular Form. Step 2: Create a Tabular Form where we need to search record. Step 3: Add the following query in region source of the Tabular Form based on the columns need to search Region source: Select  Column1, Column2, Column3, Column4, . . . FROM table_name  WHERE upper(Column1) = upper(:PXX_SEARCH)  or upper(Column2) = upper(:PXX_SEARCH)  or upper(Column3) = upper(:PXX_SEARCH)  upper(Column4) = upper(:PXX_SEARCH)  or :PXX_SEARCH is null . . . Step 4: In that search field item modify ‘Submit when enter pressed ==> YES’ for quick access of values in tabular form.  

Read More