Press "Enter" to skip to content

Oracle Apex: Download CSV from Interactive Report from Another Page

This Oracle Apex tutorial shows, how to download a CSV file from the interactive report by calling it from another page with parameters. It will directly download the CSV file without opening that page having the interactive report.

To demonstrate this example, I am using the following EMPLOYEES table:

CREATE TABLE  "EMPLOYEES" 
   (  "EMPLOYEE_ID" NUMBER(6,0), 
   "FIRST_NAME" VARCHAR2(20), 
   "LAST_NAME" VARCHAR2(25), 
   "EMAIL" VARCHAR2(25), 
   "PHONE_NUMBER" VARCHAR2(20), 
   "HIRE_DATE" DATE, 
   "JOB_ID" VARCHAR2(10), 
   "SALARY" NUMBER(8,2), 
   "COMMISSION_PCT" NUMBER(2,2), 
   "MANAGER_ID" NUMBER(6,0), 
   "DEPARTMENT_ID" NUMBER(4,0)
   )
/

You can create this table in your schema and insert some data to practice this example.

1. Create a Page in Oracle Apex for the Interactive Report

I have created a page number 10 and created an Interactive Report in it with a Page Item P10_EMPID.

Used the following SQL query and the settings for the interactive report:

select EMPLOYEE_ID,
       FIRST_NAME,
       LAST_NAME,
       EMAIL,
       PHONE_NUMBER,
       HIRE_DATE,
       JOB_ID,
       SALARY,
       COMMISSION_PCT,
       MANAGER_ID,
       DEPARTMENT_ID
  from EMPLOYEES
 where employee_id = :P10_EMPID

Page Items to Submit: P10_EMPID

Below is the screenshot of the above settings:

Oracle Apex Interactive Report with Page Item

2. Set the Attributes of the report as shown in the below image

Oracle Apex Interactive Report Attributes

Save the changes for Page 10. Now we will call this report from another page with that page’s Employee ID as a parameter to Page 10.

3. Create a Button on Another Page to Download CSV file

I have a Page 3 in my application having the item P3_EMPLOYEE_ID.

I created a button “Download CSV” with target action to “Redirect to URL” and added the following URL in it:

f?p=&APP_ID.:10:&SESSION.:CSV:NO:RP:P10_EMPID:&P3_EMPLOYEE_ID.

You can notice in the above URL, that I am passing the page item P3_EMPLOYEE_ID as a parameter to page 10 item P10_EMPID. Also, you can change the CSV to other formats such as PDF, XLS, RTF, etc.

Below is the screenshot:

Oracle Apex button for custom URL.

Save the changes for the page and run the page to test.

Now when you will click on the Button Download CSV it will directly download the CSV for the employee id stored in page item P3_EMPLOYEE_ID.

Below is the sample of CSV content:

"Employee Id","First Name","Last Name","Email","Hire Date","Job Id","Salary","Commission Pct","Manager Id","Department Id","Phone Number"
"103","Alexander","Hunold","AHUNOLD","03-JAN-06","IT_PROG","9000","","102","60","590.423.4567"

See also:

Have you found the answer to your question? If not, you can discuss it with me in the comments section below or join my Q&A community OrclQA.com for developers and ask your question. It is FREE.

Vinish Kapoor

Follow

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. foxinfotech.in is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

guest
7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Teena
Teena
4 months ago

HI Vinish,

Can we implement Download functionality for Interactive Grid in the form of a button rather than default Actions -> Download option.

Teena
Teena
Reply to  Vinish Kapoor
4 months ago

HI , Is it possible to display the DOwnload button in another location …say Below region ?
Thank you so much for your quick response.

Teena
Teena
Reply to  Vinish Kapoor
4 months ago

Actually i have a requirement to add Download and Upload functionality for my IG. I used a github plugin Download APEX Report [Plugin] for IG download. FOr some reason this give a Security Violation! error . Same plugin works well for classic report and IR. I am looking for Download and Upload buttons to locate side by side , may be on the region Edit … Hence the issue.

I tried the javascript you suggested and it does work well…but is there any way i can incorporate Upload Button [which has a Dynamic Action defined] also there.

Thank you

Teena
Teena
Reply to  Vinish Kapoor
4 months ago

Thank you so much for your suggestions, it worked well for me.

Rose Wood
Rose Wood
2 months ago

Hi Vinish,

Is it posible to do customizing/editing the Action menu item => download for Interactive Report. For example show/hide the download menu option using JS in APEX 5 IR report.

Thanks you.
Rose