Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Writing to an Excel(xlsx,2007 format) using PL/SQL

825944Dec 22 2010 — edited Dec 22 2010
Hi,

I have a new requirement in which I have to write to an excel ,.xlsx(2007 format). I am using Oracle 9i.

When I try to write it to .xlsx it is writing but when i try to open the file it says "excel 2007 excel cannot open the file because the file format or file extension is not valid".

I am using the following Stored Procedure:

create or replace
procedure myfilewrite( p_location IN varchar2,
p_filename IN varchar2)
IS
v_disk_file utl_file.file_type;

BEGIN
v_disk_file := utl_file.fopen( location => p_location,
filename =>p_filename,
open_mode=>'W');

utl_file.put_line(v_disk_file,'abc'||chr(13));
utl_file.fclose(v_disk_file);

EXCEPTION
when utl_file.invalid_path then
utl_file.fclose(v_disk_file);
raise_application_error(-2001,'path error');
when utl_file.invalid_operation then
utl_file.fclose(v_disk_file);
raise_application_error(-2002,'invalid operation error');
when utl_file.write_error then
utl_file.fclose(v_disk_file);
raise_application_error(-2003,'write error');
when utl_file.invalid_filehandle then
utl_file.fclose(v_disk_file);
raise_application_error(-2004,'filehandler error');
when others then
raise_application_error(-2005,'could not write to file');
END;

Please help me regarding this issue.

Regards,

RAJ
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 19 2011
Added on Dec 22 2010
9 comments
5,915 views