Export .Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am using Response.ContentType = "application/vnd.ms-excel" to export an
asp page to excel. Nice feature, however, it does not seem to like style
sheets. Because of this, my excel file doesn't look as nice as my asp page.

Is there any way around this without re-writing page?
Any help would be great.

Dianna
 
Hi Dianna,

What you are doing is actually setting the MIME type of the ASP output to
the Excel MIME type. If the MIME type is registered on the computer on which
you are downloading this, it thinks that the output is actually an Excel file
and uses Excel to open the response.

While this works fine, remember that it is just Excel's ability to
"understand" a HTML-table based sheet that is helping you do this. Obviously
Excel does not understand style-sheets since it wasn't built for that.

To achieve this in your own style, you might want to have a HTML table with
embedded style content such as having your <font> tags and <td bgcolor..>
values all into the HTML code. You could have a seperate ASP file with this
HTML syntax (so as to not disturb your existing code) and redirect to that
for Excel download.

A more robust solution though is to do more realistic Excel code generation
by writing some code using the Excel automation objects. You will find sample
code for the same in MSDN or many other code sites. With your current means,
the file won't be recognized as Excel if your end-user does not have the
Excel MIME type registered on their computer for some reason.

Regards,
Pandurang
 
Back
Top