5 Replies Latest reply: Jan 21, 2010 9:34 AM by 730428 RSS

    Column Alignments in HTM output

    sharpe
      Hi. I have a SQL script below that outputs 3 columns to an HTM file. It's working without error, but I've noticed that when viewing the HTM output that the column names are centered, but the column values are all left justified. Despite everything I've tried I can't seem to get either the column Names to align left or the column Values to align center. Note that in the code below I've attempted to use the JUSTIFY opition on each column, but it appears to have no affect in the output.

      Can anyone help?


      set term off;
      set echo off;
      set feedback off;
      set verify off;
      set head on;
      set pages 99;
      set pagesize 50;
      set linesize 80;
      SET MARKUP HTML ON SPOOL ON HEAD "<TITLE>ADDS Report</title> -
      <STYLE TYPE='TEXT/CSS'><!--BODY {background: ffffc6} --></STYLE>"
      spool /usr/IBM/WebSphere/AppServerCommunityEdition/repository/default/TTMSWeb/12
      22365662123/TTMSWeb-1222365662123.war/scanner_returns_report.htm;
      ttitle 'Scanner Returns';
      col Device_Status format a13 HEADING 'Device Status' JUSTIFY LEFT;
      col Total format a5 HEADING 'Total' JUSTIFY CENTER;
      col Staff format a15 HEADING 'Staff' JUSTIFY RIGHT;
      select b.device_status Device_Status, rtrim(count(a.reporter)) Total, c.first_na
      me||' '||c.last_name||'('||c.guid||')' Staff
      from scanner_assignment a, scanner_inventory b, pwc_employee c
      where a.manufacturer_nm = b.manufacturer_nm
      and a.serial_num = b.serial_num
      and a.modify_by = c.guid
      and trunc(a.return_dt) = trunc(sysdate-1)
      and a.modify_by='&1'
      and b.device_status='0'
      and b.device_status in('0','8')
      group by c.first_name||' '||c.last_name||'('||c.guid||')', b.device_status
      order by c.first_name||' '||c.last_name||'('||c.guid||')', b.device_status;
      spool off;
      exit
      /
        • 1. Re: Column Alignments in HTM output
          730428
          Hi,

          the JUSTIFY option justifies only the column header, not the column content.
          Column content is justified based upon the data type.

          When MARKUP is HTML JUSTIFY has no effect:
          SQL> select 'asdgahdg' mycol from dual;
          
          MYCOL
          --------
          asdgahdg
          
          SQL> col mycol jus left
          SQL> r
            1* select 'asdgahdg' mycol from dual
          
          MYCOL
          --------
          asdgahdg
          
          SQL> col mycol jus right
          SQL> r
            1* select 'asdgahdg' mycol from dual
          
             MYCOL
          --------
          asdgahdg
          
          SQL> col mycol jus center
          SQL> r
            1* select 'asdgahdg' mycol from dual
          
           MYCOL
          --------
          asdgahdg
          
          SQL> SET MARKUP HTML ON 
          SQL&gt; r
          <br>
            1* select 'asdgahdg' mycol from dual
          <br>
          <p>
          <table border='1' width='90%' align='center' summary='Script output'>
          <tr>
          <th scope="col">
          MYCOL
          </th>
          </tr>
          <tr>
          <td>
          asdgahdg
          </td>
          </tr>
          </table>
          <p>
          
          SQL&gt; col mycol jus right
          <br>
          SQL&gt; r
          <br>
            1* select 'asdgahdg' mycol from dual
          <br>
          <p>
          <table border='1' width='90%' align='center' summary='Script output'>
          <tr>
          <th scope="col">
          MYCOL
          </th>
          </tr>
          <tr>
          <td>
          asdgahdg
          </td>
          </tr>
          </table>
          <p>
          Max
          [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]
          • 2. Re: Column Alignments in HTM output
            MichaelS
            I can't seem to get either the column Names to align left or the column Values to align center.
            Extend your style sheet commands with alignment directives as e.g. in

            e.g.:
            SQL> set markup html on entmap off head "<style type=""text/css""><!-- td {text-align: center} --></style>" spool  on
            • 3. Re: Column Alignments in HTM output
              sharpe
              Massimo Ruocchio, thank you so much for taking the time to post the SQL HTML examples with the 'set markup html on' option.

              But I'm not seeing the difference in the output in the last two examples. Even after using the 'col mycol jus right' option the output appears the same:

              What am I missing?
              • 4. Re: Column Alignments in HTM output
                sharpe
                michaels2, Thanks so much.
                • 5. Re: Column Alignments in HTM output
                  730428
                  You're missing nothing.
                  It's exacly what I wanted to show:

                  I wrote:
                  When MARKUP is HTML JUSTIFY has no effect:
                  So the two last examples give identical resilts.


                  Max
                  [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/17/supporto-di-xml-schema-in-oracle-xmldb/]