Hi,
I now think I understand what you're talking about, and remember hitting the same thing a few years ago - that the CSS injected with the CSSSTYLE option had some ODS-specific expectations/limitations as it processed it before outputting. If your requirement is for web-only output, the following alternative way of injecting CSS into your ODS will work better as it just loads it explicitly into the page source and lets the browser interpret it natively:
ods html5 file=_webout stylesheet=(URL="/ht/test.css");
* where /ht/test.css is a URI on your webserver ;
Keep in mind that this displaces the original CSS that would have been injected as a <style> tag at the top of your ODS output, so you'll want to grab that from an original report and use it as a template that you then modify. However this basic stylesheet= option should give you expected behaviour precisely as it replaces that <style> segment with a <link href="/ht/test.css" rel="stylesheet"/> element in the head.
I've just done some testing to make sure I'm right on this, including an example for your selection methods question. First, the standard SAS output:
ods html5 file=_webout;
Proc Print data=sashelp.class;
run;
ods html5 close;
obviously produces this:
I created the following CSS file and saved it under /pub/ht/test.css, which is exposed via the web as /ht/test.css:
Injecting the CSS into the ODS with your cssstyle method produces this:
Again this is because ODS I guess tries to 'translate' the generic CSS into ODS-compatible CSS, picking out the properties it knows about. If I view the page source it actually comes out as the following:
td, th { text-align: left; padding: 3px 6px; vertical-align: top } /* other bits */ .table {
background-color: #f0f0f0;
border: 0 solid #dddddd;
border-collapse: separate;
border-spacing: 0;
font-family: "Open Sans";
font-size: small;
font-style: normal;
font-weight: normal;
}
Using this method, the td, tm bit gets ignored and ODS does its own thing (like you say). This seems to be the case with a lot of other boilerplate CSS that is generated inside that <style> tag. However, with the .table selector it actually does do stuff; it tries to convert as much of it as possible and inject it, but still only includes the properties it knows about, as per above.
Now, using the third method, stylesheet=(URL="/ht/test.css"), the output looks like this:
This is because the CSS is being interpreted by the browser directly, and I assume is the behaviour you were after / expecting. As long as you're not looking for your CSS to be portable across non-web versions of the STP reports (ie. in Enterprise Guide), then this should do the trick. It seems that neither method tries to override existing CSS properties, instead just displacing the entire style spec with whatever you give it. The cssstyle option, for example, generates a .toc tag for the title that is hidden (display:none), whereas the stylesheet= option just displaces all CSS that ODS would have generated. This is why you'll need to also make sure your enterprise-wide SAS CSS file covers all of the styling that would have been included by the original ODS generated style tag.
Hope that answers your question.
Nik
... View more