Link to home
Start Free TrialLog in
Avatar of mainrotor
mainrotor

asked on

I need help using Response.ContentType = "application/vnd.ms-excel" in ASP.net

Hi Experts,
I have an ASP.Net application with VB.Net codebehind.  I want to use Response.ContentType = "application/vnd.ms-excel" to display the output in Excel, but it's not working.  What am i doing wrong (see vb.net codebehind, below)?


Partial Class _Default
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.ContentType = "application/vnd.ms-excel"

        Dim strString As String
        strString = "<table><tr><td>1</td><td>2</td><td>3</td><td>4</td></tr></table>"
        Response.Write(strString)
    End Sub

End Class


Thanks in advance,
mrotor  
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

try :
Response.AddHeader("content-type", "application/vnd.ms-excel")



Avatar of mainrotor
mainrotor

ASKER

No that didn't work.
i duuno what is this vnd.ms-excel is about.

if you are trying to generate some special kind of content, i think the part about table...tr..td won't work.
that's for html. unless your vnd.ms-excel can read/render normal html file.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial