The SAS Output Delivery System and reporting techniques

Justifying Columns in HTML Excel Files

Reply
Contributor
Posts: 21

Justifying Columns in HTML Excel Files

I am trying to create some very simple spreadsheets using HTML (XML output is too large) but would like to right-justify certain columns from a PROC PRINT. I've tried using .r style with HTMLCSS, but didn't get anywhere. Not sure what else to try...?
SAS Super FREQ
Posts: 8,743

Re: Justifying Columns in HTML Excel Files

Hi:
I tried this with ODS HTML3
[pre]
title; footnote;
ods html3 file='c:\temp\testjust_ht3.xls' style=sasweb;
proc print data=sashelp.class;
var name /style(data)={htmlstyle="text-align:right;" cellwidth=1in};
var age height;
run;
ods html3 close;
[/pre]

And when I opened the HTML 3.2 file with Excel, the Name was right-justified (I made the cellwidth bigger, so you could see the effect without enlarging the name column manually).

There must be some difference between HTML 3.2 (ODS HTML3) and the HTML generated by HTMLCSS (ODS HTMLCSS) and Excel's interpretation of the 2 versions of HTML tags -- The "vanilla" HTML 3.2 file and text-align worked with Excel and the HTMLCSS-generated file did not (even though it was HTML 3.2). Very strange -- but it didn't work at all with regular ODS HTML (HTML 4.0 tags) or ODS MSOFFICE2K (MS-HTML tags) -- so I suspect some HTML/Excel strangeness at work.

If you must use HTMLCSS or HTML4, then you might consider contacting Tech Support for further help.

cynthia
Contributor
Posts: 21

Re: Justifying Columns in HTML Excel Files

That did it!

Thanks as always, Cynthia
Contributor
Posts: 21

Re: Justifying Columns in HTML Excel Files

Cynthia,

When using the same approach with Proc Report, I do not seem to be able to force the column width using CELLWIDTH...does that option not work in Proc Report in HTML 3.2 code?

Thanks,
Kryn
SAS Super FREQ
Posts: 8,743

Re: Justifying Columns in HTML Excel Files

Hi:
Well, it may be Tech Support time...when I do this:
[pre]
title; footnote;
ods html3 file='c:\temp\testjust_ht3x.xls' style=sasweb;

proc report data=sashelp.class nowd;
define name /style(column)={htmlstyle="text-align:right;" cellwidth=2in};
define age / display;
define height /display;
run;
ods html3 close;
[/pre]

I get name right-aligned in a BIGGER column -- is it really 2 inches??? It doesn't look like it to me, but it IS bigger than it is without the CELLWIDTH style override.

So, I'm not sure what's happening.

cynthia
Ask a Question
Discussion stats
  • 4 replies
  • 155 views
  • 0 likes
  • 2 in conversation