The SAS Output Delivery System and reporting techniques

How do I insert an image into my .xls and it not be a link?

Posts: 33

How do I insert an image into my .xls and it not be a link?


I am using the following code to include an image in my .xls. I am using ODS HTML to control cell colours but this code inserts a link I think? Is it possible to include an image inside the excel spread and it NOT just be a link to an image?

proc report data= xxx nowd split='\' headline headskip
style(Report)=[preimage="xxx.jpg" vjust=top] nowindows ;
columns label header;
define label / display '';
define header / display '';
title ' test title';

Posts: 8,743

Re: How do I insert an image into my .xls and it not be a link?

When you call your file "an .xls", then I imagine you have done this:
ods html file='myfile.xls';

When you use ODS HTML to create an ASCII text file, the information in the file is in HTML format -- your information from SAS is delimited by HTML tags (like <TABLE> and <TD> tags). Excel has been able to open HTML files ever since Office 97, however, Excel is only reading the HTML tags and rendering the HTML table (including images) into spreadsheet form.

Naming your file .XLS does not make the file a true, binary Excel file, in Microsoft proprietary format. It merely "fools" the Windows Registry into launching when the file is clicked --or makes Excel the default application to open the file. If you look at your ODS HTML file with Notepad, you will still see HTML tags inside the file.

As an HTML file, the correct way to point to images is with an <IMG> tag. Therefore, when you use the PREIMAGE style attribute, ODS builds an <IMG> tag. I believe that if you save your HTML file with an image as a proprietary Excel file (Excel 97-2003 xls), that the image will be converted to "internal" Excel format. You might be able to automate this process of saving the HTML file to proprietary format with an Excel macro or VBA script.

If you use the ODS RTF or ODS PDF destinations, then your image is converted to internal RTF or PDF format, when the file is created and the image is essentially embeddeded into either of those output files.

Posts: 33

Re: How do I insert an image into my .xls and it not be a link?

Thank you :-)
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation