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

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

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.

Advertisements
Categories: ApEx
  1. February 1, 2008 at 3:49 am

    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?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: