Andy’s Blog: Application Express etc.


ApEx: Conditionally display “Export to Excel/CSV” Link

Posted in ApEx by Andrew Tulley on June 24, 2007

From within Report Attributes for a report it is possible to turn on “Enable CSV Output” which causes a link to be displayed below the report which, when clicked, downloads a .CSV representation of the data in the report. Very useful. However, this turns on the “Export to CSV” link for all users. What if you want to make this link available to only a subset of your users?

To achieve this you can do the following:

1) Add a hidden item to the page that contains your report. Call it something like PX_CSV_LINK_TEXT where x should be replaced with the page number.

2) Under Report Attributes for your report, under the “Report Export” options, set “Link Label” to:

&PX_CSV_LINK_TEXT.

3) Add an “On Load – Before Header” Page Process of type PL/SQL setting its source to something like the following:

IF APEX_UTIL.current_user_in_group('ADMIN') THEN
:PX_CSV_LINK_TEXT := 'Export to .CSV';
ELSE
:PX_CSV_LINK_TEXT := NULL;
END IF;

Change the logic in step 3 to fit your particular requirements. The example above will display the “Export to .CSV” link only if the user is a member of the ADMIN user group.

One Response to 'ApEx: Conditionally display “Export to Excel/CSV” Link'

Subscribe to comments with RSS or TrackBack to 'ApEx: Conditionally display “Export to Excel/CSV” Link'.

  1. ROCIO said,

    Hi I like your article. it’s handy but to complex this topic how can I include in my .csv report a field from the report region which is hidden . any idea?


Leave a Reply