Thursday, July 15, 2010

Oracle: Spool to Excel from SQLPlus

Spooling the output from SQLPlus to log file is often in unreadable format.

To Spool SQLPLus output to Excel (.xls) file, the trick is to turn On "MARKUP HTML"

SQL>set markup html on
SQL>set feedback off

SQL>spool c:\test.xls

SQL>select * from user_objects where rownum <= 20;
SQL>spool off

SQL>set markup html off

11 comments:

  1. same post here :

    http://chandu208.blogspot.com/2012/01/spool-command.html

    ReplyDelete
  2. See some examples here..
    http://shonythomas.blogspot.in/2011/07/export-and-create-excel-file-from.html

    ReplyDelete
  3. Much useful info. Thank you!!.

    ReplyDelete
  4. very helpful.. Thanks..

    ReplyDelete
  5. But the file is saved in HTML format.
    Opening this file in Excel will not pose any problem because Excel can read HTML format, but other software will return invalid file format.

    I had to open this file in Excel, then click SAVE AS XLS again.

    ReplyDelete
  6. Great info, thanks!

    ReplyDelete
  7. Worked, thank you!

    ReplyDelete