【问题标题】:CSS Style in SAS: Outside Double Border on TableSAS 中的 CSS 样式:表格外部双边框
【发布时间】:2015-09-22 16:48:34
【问题描述】:

下面的 sn-p 实际上会生成一个类似于我在此处运行时想要的表格,但是输出的 RTF 文件显示了一个没有内边框的不同表格。这怎么可能?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="Generator" content="SAS Software Version 9.3, see www.sas.com">
<meta http-equiv="Content-type" content="text/html; charset=windows-1252">
<title>SAS Output</title>
<style type="text/css">
<!--
.table {
	color: #000000;
	font-family: 'Arial', 'Arial';
	font-size: 10pt;
	font-style: normal;
	font-weight: normal;
	border: medium double black;
 }
.proctitle{
	color: #000000;
	font-family: Arial, 'Albany AMT', Arial;
	font-size: x-small;
	font-style: normal;
	font-weight: bold;
 }
.systemtitle{
	font-family: Arial, 'Albany AMT', Arial;
	font-size: large;
	font-weight: 14pt;
	color: black;
 }
.header, .rowheader, .footer, .rowfooter{
	color: black;
	font-size: 10pt;
	font-family: Arial, 'Albany AMT', Arial;
	background-color: #ffffff;
	font-weight: bold;
	text-align: center;
	vertical-align: middle;
	padding: 10px;
 }
.data{
	font-size: 10pt;
	font-family: Arial, 'Albany AMT', Arial;
	background-color: #ffffff;
	text-align: center;
	vertical-align: middle;
	padding: 10px;
 }
.l {text-align: left }
.c {text-align: center }
.r {text-align: right }
.d {text-align: right }
.j {text-align: justify }
.t {vertical-align: top }
.m {vertical-align: middle }
.b {vertical-align: bottom }
TD, TH {vertical-align: top }
.stacked_cell{padding: 0 }
-->
</style>
<script language="javascript" type="text/javascript">
<!-- 
function startup(){

}
function shutdown(){

}

//-->
</script>

</head>
<body onload="startup()" onunload="shutdown()" class="body">

<script language="javascript" type="text/javascript">
<!-- 
var _info = navigator.userAgent
var _ie = (_info.indexOf("MSIE") > 0
          && _info.indexOf("Win") > 0
          && _info.indexOf("Windows 3.1") < 0);
var _ie64 = _info.indexOf("x64") > 0

//-->
</script>

<div class="branch">
<a name="IDX"></a>
<table class="systitleandfootercontainer" width="100%" cellspacing="1" cellpadding="1" rules="none" frame="void" border="0" summary="Page Layout">
<tr>
<td class="c systemtitle">Example Title Here</td>
</tr>
</table><br>
<div>
<div align="center">
<table class="table" cellspacing="0" cellpadding="5" rules="all" frame="box" bordercolor="#C1C1C1" summary="Procedure Print: Data Set WORK.TEST">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="l header" scope="col">CAR</th>
<th class="r header" scope="col">YEAR</th>
</tr>
</thead>
<tbody>
<tr>
<td class="l data">FORD</td>
<td class="r data">1995</td>
</tr>
<tr>
<td class="l data">HONDA</td>
<td class="r data">1998</td>
</tr>
<tr>
<td class="l data">CHEVY</td>
<td class="r data">2001</td>
</tr>
</tbody>
</table>
</div>
</div>
<br>
</div>
</body>
</html>

但是,这会生成一个这样的表:

我希望它看起来像:

我创建了以下数据集并使用ODS RTF 和我的自定义.css 文件(在本例中称为 TESTFOX)来输出表格:

DATA TEST;
    INPUT CAR $10. YEAR;
    DATALINES;
    FORD    1995
    HONDA   1998
    CHEVY   2001
    ;
RUN;

ODS RTF FILE="C:\USERS\DOCUMENTS\TEST.RTF" CSSSTYLE='C:\USERS\DOCUMENTS\TESTFOX.CSS';
PROC PRINT DATA=TEST NOOBS;
RUN;
ODS _ALL_ CLOSE;

【问题讨论】:

    标签: html css templates sas border


    【解决方案1】:

    使用nth child 选择器。下面的 CSS 可能会根据您的 html 结构起作用。

    tr:first-child {
      border-top: medium double black;
    }
    tr:first-child {
      border-bottom: medium double black;
    }
    td:first-child {
      border-left: medium double black;
    }
    td:last-child {
      border-right: medium double black;
    }

    编辑

    在原海报添加了一些细节之后,这里有一个可能的方法来获取内边框。

    td, th {
        border: thin solid black;
    }
    

    【讨论】:

    • 我提供的代码是整个结构。我看到nth child 正在尝试做什么,但我不太确定如何嵌入代码。添加.tr.td 之类的句点并附加到整个代码后,它不起作用。
    • 我只是使用 Notepad++ 来编辑上面的代码,它是一个 .css 文件,然后我使用 SAS 调用这个 .css 文件来设置输出表的样式。如果有意义的话,我认为没有 HTML 代码?
    • @Foxer 在 SAS 的结果窗口中,您应该能够右键单击它并选择“查看 HTML 源代码”(或类似内容)。
    • @RobertPenr​​idge 代码有 1500 行,所以我粘贴了前几行来展示它的结构。之后,代码以我上面显示的.table { 开头。这会有帮助吗?
    • @Foxer 这是朝着正确方向迈出的一步,但我们只需要 HTML 的相关部分。具体来说,您尝试格式化的表格的 HTML 源代码,以及表格使用的任何 CSS 样式的定义。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-10
    • 2015-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多