Q:

Setting column headings on report export

I'm using the following blog post to help me export a report. It works great however i wondered is it possible to set column heading names?
http://spendolini.blogspot.co.uk/2006/04/custom-export-to-csv.html

A:

If all you want to do is to provide an initial row with column headers in it:
begin
   -- Set the MIME type
   owa_util.mime_header( 'application/octet', FALSE );
   -- Set the name of the file
   htp.p('Content-Disposition: attachment; filename="emp.csv"');
   -- Close the HTTP Header
   owa_util.http_header_close;
   -- Send the initial row with headers
   htp.prn('Ename,Empno,Department'||chr(13));
   -- Loop through all rows in EMP
   for x in (select e.ename, e.empno, d.dname
             from emp e, dept d where e.deptno = d.deptno
             and e.deptno like :P1_DEPTNO)
   loop 
   -- Print out a portion of a row, 
   -- separated by commas and ended by a CR
   htp.prn(x.ename ||','|| x.empno ||','||
            x.dname || chr(13));
   end loop;
   -- Send an error code so that the
   -- rest of the HTML does not render
   --htmldb_application.g_unrecoverable_error := true;
   --use stop apex_engine 
   apex_application.stop_apex_engine;
end;

Basically you just emit one extra row before you emit the data rows.
I commented htmldb_application in favor of apex_application.stop_apex_engine. See documentation

