CSS File Embedded on an Excel Spreadsheet

ColdFusion - Excel - CSS

I have created a report using an Excel spreadsheet, converted it into a ColdFusion Template and populated it.  The problem is the cell formatting (colors, font,etc) is all done in a CSS file.  Is there any way to export such that the CSS is embedded (or something) so I don't lose the coloring or I don't have to go and apply the colors directly to each cell?

I am using the following link on my head tags:

<head>

   <link rel="stylesheet" type="text/css" href="excel.css">
   <cfheader name="content-disposition" value="attachment; filename=test.xls">
   <CFCONTENT TYPE="application/vnd.ms-excel"></cfcontent>

</head>
jramos74Asked:
Who is Participating?
 
GrandSchtroumpfCommented:
In real HTML+CSS, you can place the content of the excel.css file inside a <style> tag:

<head>

   <cfheader name="content-disposition" value="attachment; filename=test.xls">
   <CFCONTENT TYPE="application/vnd.ms-excel"></cfcontent>
   <style type="text/css">
      { content goes here}  
   </style>

</head>

Now, since this is excel, i cannot guarantee that it will work.
0
 
jramos74Author Commented:
THe content of my css file was inside the style tag, but I have so many styles and settings so I decided to put all the styles on a separate file.  

I have done this before with Word and it work perfectly.  I am not sure why it will not work for Excel.
0
 
GrandSchtroumpfCommented:
Well, you need to choose, either you embed it or you don't... you cannot do both at the same time.
You can keep the css in a separate file you your server and just include it using a CF function.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jramos74Author Commented:
That is what I did.  I put all the styles on one .css file.  When I try to use it above, it will not recognize the file.
0
 
GrandSchtroumpfCommented:
You used a <link> tag which is the HTML way to include an external CSS file.
You need to include the CSS using a CF include... something like this:

<head>

   <cfheader name="content-disposition" value="attachment; filename=test.xls">
   <CFCONTENT TYPE="application/vnd.ms-excel"></cfcontent>
   <style type="text/css">
      <cfinclude template="excel.css">
   </style>

</head>
0
 
jramos74Author Commented:
I did exactly what you coded above. When I run the template I did not get the styles and settings instead it outputed the code inside the .css file.  I will keep on trying other ways.  Thank you Grandschtroumpf for your help.  I am not familiart with CSS that much.  If you have another suggestions, I would love to try it.  Worst case, I will just embed the styles inside the style tags.  I just want to make my template much easier to read.  That is why I am putting the styles on a separate file.
0
 
GrandSchtroumpfCommented:
> I did not get the styles and settings instead it outputed the code inside the .css file.
That's definitely not what i expected from <cfinclude>...
I never used Cold Fusion, but it relly seems like <cfinclude> is for including files:
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p63.htm
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.