Response.ContentType = "application/ms-excel"

Discussion in 'ASP General' started by jrasmussen@idealas.com, Oct 26, 2005.

  1. Guest

    I have created an Excel spreadsheet for the web. When it opens in IE
    6.0 I get the message that the format is not supported. This is because
    it is in tab delimited format. Ane when I save the file, It saves it as
    txt. How can this file be created so that Excel sees it as an .xls
    format. I created the data in VB 6.0 with a vbtab to seperate the
    columns.

    Hope this is enough information.

    Thanks for the help,
    Jim
     
    , Oct 26, 2005
    #1
    1. Advertising

  2. Create an actual Excel file. A tab delimited file is not the same as an
    Excel file. You created the file programatically?

    If you do it as a csv and give it a csv extension, it's more than likely
    that it'll open in Excel on most machines. But even then, that does not
    mean that it's an Excel file. It's then just a comma separated values file.

    Ray at work

    <> wrote in message
    news:...
    >I have created an Excel spreadsheet for the web. When it opens in IE
    > 6.0 I get the message that the format is not supported. This is because
    > it is in tab delimited format. Ane when I save the file, It saves it as
    > txt. How can this file be created so that Excel sees it as an .xls
    > format. I created the data in VB 6.0 with a vbtab to seperate the
    > columns.
    >
    > Hope this is enough information.
    >
    > Thanks for the help,
    > Jim
    >
     
    Ray Costanzo [MVP], Oct 26, 2005
    #2
    1. Advertising

  3. I didn't notice the subject and that you were setting the application type.
    If you're going to do that, just return an html table, not tab delimited
    data. Excel will handle converting an html table to a spreadsheet.

    Ray at work

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:%...
    > Create an actual Excel file. A tab delimited file is not the same as an
    > Excel file. You created the file programatically?
    >
    > If you do it as a csv and give it a csv extension, it's more than likely
    > that it'll open in Excel on most machines. But even then, that does not
    > mean that it's an Excel file. It's then just a comma separated values
    > file.
    >
    > Ray at work
    >
    > <> wrote in message
    > news:...
    >>I have created an Excel spreadsheet for the web. When it opens in IE
    >> 6.0 I get the message that the format is not supported. This is because
    >> it is in tab delimited format. Ane when I save the file, It saves it as
    >> txt. How can this file be created so that Excel sees it as an .xls
    >> format. I created the data in VB 6.0 with a vbtab to seperate the
    >> columns.
    >>
    >> Hope this is enough information.
    >>
    >> Thanks for the help,
    >> Jim
    >>

    >
    >
     
    Ray Costanzo [MVP], Oct 26, 2005
    #3
  4. Patrice Guest

    AFAIK this is not the proper mime type.

    Try :
    .xls application/excel
    .xls application/vnd.ms-excel
    .xls application/x-excel
    .xls application/x-msexcel


    (from http://www.webmaster-toolkit.com/mime-types.shtml)

    I used the second one...


    --

    <> a écrit dans le message de
    news:...
    > I have created an Excel spreadsheet for the web. When it opens in IE
    > 6.0 I get the message that the format is not supported. This is because
    > it is in tab delimited format. Ane when I save the file, It saves it as
    > txt. How can this file be created so that Excel sees it as an .xls
    > format. I created the data in VB 6.0 with a vbtab to seperate the
    > columns.
    >
    > Hope this is enough information.
    >
    > Thanks for the help,
    > Jim
    >
     
    Patrice, Oct 26, 2005
    #4
  5. Guest

    Here is the code that I have...

    For Each eXml In xnlXml
    For Each aAttr In eXml.Attributes
    If aAttr.baseName <> "balance_due" Then
    sXLSFile = sXLSFile & aAttr.Value & vbTab
    Else
    sXLSFile = sXLSFile & aAttr.Value & vbCrLf
    End If
    Next aAttr
    Next eXml

    Randomize
    sFileName = Server.MapPath("dreamreport") & CStr(CInt(Rnd(100) * 1000))
    & ".xls"
    Set oFso = CreateObject("Scripting.FileSystemObject")
    oFso.CreateTextFile sFileName
    Set fFile = oFso.GetFile(sFileName)
    Set tStream = fFile.OpenAsTextStream(ForWriting)

    Then sFileName and sXLSFile are sent to..

    bRtn = True
    Response.Expires = 0
    Response.Buffer = True
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader "Content-Disposition", "inline; filename=" &
    p_bstrFilename
    Response.AddHeader "Content-Length", LenB(p_vBuffer)
    Response.BinaryWrite p_vBuffer

    And I still get that message that the file cannot be recognized.

    Thanks for any help,

    Jim
     
    , Oct 26, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alien2_51

    Response.ContentType

    alien2_51, Jun 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    761
    alien2_51
    Jun 26, 2003
  2. Bart Vanwesemael
    Replies:
    1
    Views:
    527
    William F. Robertson, Jr.
    Jul 28, 2003
  3. TJS
    Replies:
    5
    Views:
    1,068
    Alvin Bruney
    Nov 19, 2003
  4. =?Utf-8?B?RXlhbCBaaW5kZXI=?=

    Response.ContentType and Viewstate problem

    =?Utf-8?B?RXlhbCBaaW5kZXI=?=, Apr 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    456
    =?Utf-8?B?RXlhbCBaaW5kZXI=?=
    Apr 22, 2004
  5. Katie
    Replies:
    8
    Views:
    268
    Anthony Jones
    Aug 17, 2006
Loading...

Share This Page