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

Breadcrumb

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 19.1.0.00.15

Viewed 1000+ 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 Connor 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

declare
    l_export       apex_data_export.t_export;
    l_region_id    number;
begin
   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);
         
    apex_data_export.download( l_export );
end;


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

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

       apex_json.open_object;
       apex_json.write_context( 'data', l_context );
       apex_json.close_object;
   end;


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



Is this answer out of date? If it is, please let us know via a Comment

More to Explore

APEX

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