Skip to Main Content
  • Questions
  • Allow user to export all reports to Excel


Question and Answer

Connor McDonald

Thanks for the question, Tsecheng.

Asked: March 31, 2021 - 4:37 pm UTC

Last updated: April 07, 2021 - 3:26 am UTC

Version: Application Express

Viewed 100+ times

You Asked

I have a page which includes 4 regions. All are Classic Reports. I set "Yes" for "CSV Export Enabled" under Attributes/Download of each Classic Report.

Is there any way to build in functionality that allow user to export all of classic reports to Excel at once as opposed to having to do so one at a time?

and we said...

The easiest way is going to be upgrading to APEX 20 where we have the APEX_DATA_EXPORT routine. Then it would be a case of calling the API to unload your data to any form you like, eg

    l_export       apex_data_export.t_export;
    l_region_id    number;
   select region_id into l_region_id
     from apex_application_page_regions
    where application_id = :APP_ID
      and page_id = :APP_PAGE_ID
      and static_id = 'my_region';
    l_export := apex_region.export_data (
         p_format       => :P3_FORMAT,
         p_page_id      => :APP_PAGE_ID,
         p_region_id    => l_region_id);
     l_export );

Before then, you might be able to get something out of apex_region.open_query_context , eg

       l_context apex_exec.t_context;
       l_context := apex_region.open_query_context (
                        p_page_id => 1,
                        p_region_id => 2505704029884282,
                        p_component_id => 880629800374638220 );

       apex_json.write_context( 'data', l_context );

I think you'll be hand-crafting a *lot* of code.

More to Explore


Keep your APEX skills fresh by attending their regular Office Hours sessions.