How to export report(read:layout) to excel file

I ‘ve been thinking how difficult to export all layout report to excel file. It may caused by  owa_sylk package just like I’ve used. It seems the best tool that I ever used, but I think it has limitation if I should parse 2 querys or more and report must be composed in formated xls file.

I’ve got an idea to put htp.init and owa_util.mime_header(‘application/vnd.ms-excel’) as header, hope that it would create .xls file as I expected :

create or replace procedure xls_view is
cursor c_data is
select * from mytable where name=me;
begin
————
htp.init;
owa_util.mime_header (‘application/vnd.ms-excel’,true);
owa_util.http_header_close;
————
htp.p(‘<table border=”1″><tr>NICK NAME<td></td><td>FULL NAME</td></tr>’);
for j in c_data
loop
htp.p(‘<tr><td>’||j.nick_name||'</td><td>’||j.full_name||'</td></tr>’);
end loop;
htp.p(‘</table>’);
exception
when others then
htp.p(”||sqlerrm||’);
end;

Yeaa..I made it, it’s work fine all data has exported. Next step, I’ve tried to put 3 table using 3 different cursors so far there’s no problem to system.

But, this methods has some limitations:
Some case, if web page composed by layers file would not created as we expected. This can be understood cause layer placed using relative-positions.

So, this method is very helpfull to export html report with data composed in tables only not using div layer. Next questions is what should we do to give a name to that file?

Filename can be define by placed this scipt before owa_util.http_header_close;
htp.print(‘Content-Disposition:attachment;filename=”somefilename.xls”‘);
If You do this, You should set owa_util.mime_header into false condition too, if You don’t filename would be created as like as Your procedure name.

3 thoughts on “How to export report(read:layout) to excel file

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s