Check out this thread:
All you need to do is build your e-mail after running the above code..
My question was to know if exists any APEX functionality to run the query of a report of a page, and insert the result into CLOB file.
The above code involves to duplicate the code, I wanted to know any way to reuse the query.
for example, if there are any way to run the request "FLOW_EXCEL_OUTPUT_R16178146249336582_en-us" and insert this in a CLOB file. Or if there are any APEX API to return the result of a report in a CLOB.
Not natively in the product, you can run a report printing to a blob, but unless you use BI Publisher you can NOT have it generate anything but a PDF via FOP/APEX Listener..
There is a plugin available (IR) Report to XLSX in which it takes a report region and dumps an XLSX version of the report to the browser. We have taken the guts of the plugin and created a function with the results returning a blob value. We have even used this function to generate spreadsheets using DBMS_JOB at midnight and exporting them to other systems. It took alittle bit of work but the functionality allowed us to create multiple sheet xlsx files from multiple regions on the same page. The developer did a great job Anton Scheffer.
Hope this helps,