[20120817]sqlplus 输出html格式.txt
许多blog介绍在sqlplus输出excel文件的方法,实际上执行的是:
set markup HTML ON
生成的是html格式的文件,只不过MS OFFICE可以当作电子表格文件打开!
利用这个特性,可以使用firefox打开.
参考链接如下:
建立html.sql文件:
http://uhesse.com/2011/06/30/sqlplus-output-in-nice-html-format/
----------------------------------------
-- get the last SQL*Plus output in HTML
-- after Tanel Poder
----------------------------------------
set termout off
set markup HTML ON HEAD " -
-
" -
BODY "" -
TABLE "border='1' align='center' summary='Script. output'" -
SPOOL ON ENTMAP ON PREFORMAT OFF
spool myoutput.html
l
/
spool off
set markup html off spool off
host "E:\Program Files\Mozilla Firefox\firefox.exe" myoutput.html
set termout on
--注意修改firefox.exe的执行路径!调用html.sql之前,先执行要输出的sql语句.
--脚本巧妙的利用sqlplus的list(l)命令,调出上次执行的sql语句.
SQL> help l
LIST
----
Lists one or more lines of the most recently executed SQL command
or PL/SQL block which is stored in the SQL buffer. Enter LIST with
no clauses to list all lines. In SQL*Plus command-line you can also
use ";" to list all the lines in the SQL buffer. The buffer has no
command history list and does not record SQL*Plus commands.
L[IST] [n | n m | n * | n LAST | * | * n | * LAST | LAST]
时间: 2024-10-14 11:56:26