【问题标题】:Set the column width when outputting to HTML using SQLPLUS?使用 SQLPLUS 输出到 HTML 时设置列宽?
【发布时间】:2015-08-03 15:29:57
【问题描述】:

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

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

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

编辑:

我尝试过类似的方法:

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

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

【问题讨论】:

    标签: oracle sqlplus


    【解决方案1】:

    您可以使用 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
    

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

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

    【讨论】:

    • 我的错误...示例实际上不起作用...宽度样式需要在 th 标签而不是 p 标签上设置。在 p 标签上设置它不能正常工作。
    【解决方案2】:

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

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-04
      • 2012-08-13
      • 1970-01-01
      • 2012-04-01
      • 1970-01-01
      相关资源
      最近更新 更多