oracle 使用 SQLPLUS 输出到 HTML 时设置列宽?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5235563/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:58:03  来源:igfitidea点击:

Set the column width when outputting to HTML using SQLPLUS?

oraclesqlplus

提问by vicsz

I am using the 'SET MARKUP HTML ON' option to output a result table from a query to html using SQLPLUS.

我正在使用“SET MARKUP HTML ON”选项将结果表从查询输出到使用 SQLPLUS 的 html。

I want to be able to explicitly specify that some columns need to be a specific pixel width.

我希望能够明确指定某些列需要具有特定的像素宽度。

Is this possibly using the 'SET MARKUP HTML OPTION' ?? I would rather not have to just use the regular spooling option, and create the html table manually.

这可能使用“SET MARKUP HTML OPTION”吗??我宁愿不必只使用常规的假脱机选项,而是手动创建 html 表。

Edited:

编辑:

I have tried something like:

我尝试过类似的事情:

SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP OFF

SPOOL file.html
column aString heading "New Heading"
column aNumber heading "<p style='width:100px'>800SetColA</p>"

SELECT 'Some long String' aString, 3 aNumber FROM dual
UNION ALL
SELECT 'Some other String' aString, 9 aNumber FROM dual;
SPOOL OFF

Which does not work!! the width style tag needs to be set on the th tag and not the p tag.

哪个不起作用!!宽度样式标签需要设置在 th 标签上,而不是 p 标签上。

回答by Harrison

You can use the COLUMN ** HEADING to do this as such:

您可以使用 COLUMN ** HEADING 来执行此操作:

SET PAGESIZE 50000
SET MARKUP HTML ON TABLE "class=detail cellspacing=0" ENTMAP OFF
column colA heading "<p style='width:800px'>800SetColA</p>" format a40

column colB heading "<p style='width:10px'>10SetColB</p>" format a40

spool test.html

select level cola, level-5 colb from dual connect by level <10 ;

spool off

you can also use style sheets via this approach, tht

你也可以通过这种方法使用样式表,tht

Some helpful links: http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b12170/ch8.htmhttp://gennick.com/html.html

一些有用的链接:http: //www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b12170/ch8.htmhttp://gennick.com/html.html

回答by user3638694

If you want to use stylesheets .. Here is an example :-

如果你想使用样式表 .. 这是一个例子:-

set markup html on spool on entmap off -
     head '-
     <style type="text/css"> -
        table { font-family: verdana,arial,sans-serif; font-size:11px;color:#333333;border-width: 1px;border-color: #666666;border-collapse: collapse; } -
        th { border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #dedede; } -
        td { border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #ffffff; } -
     </style>' 

spool op.html
exit