Generating XLS files from ASP

Discussion in 'ASP General' started by daniele.balducci, Jul 4, 2005.

  1. Hi All,
    I'm generating XLS files from ASP(.Net) code using the usual code
    chunks ...

    Response.ContentType = "application/vnd.ms-excel"
    Response.AppendHeader("Content-Disposition", "attachment; filename=""" &

    NomeFile & """")
    Response.Flush()
    Response.write("<table border=""1"" .....
    ......
    ......
    Response.end

    It all works fine since I'm able to Open/Save the file with Excel 2000. But
    .....
    ....... when I run the code on a box where only an Excel Viewer 2003 is
    installed (rather then the full product) I cannot open it, and Viewer aborts
    with the following Message : "Cannot Open files of this type".
    Choosing to save save the file to reopen it laterleads to the same error.

    Moreover, the generated XLS file looks to be really small ....(1Kb) and
    after opening and resaving it from Excel program as a xls Workbook it becomes
    larger (14Kb). At this point the viewer can open it.. ...

    All this let me think that the generated file is not a "real" xls file ....
    while viewer can only open this kind of files ... (also tried to use freeware
    viewer but I got the same behaviour .....)

    Any help is appreciated .... Thanks in advance Daniele Balducci
     
    daniele.balducci, Jul 4, 2005
    #1
    1. Advertising

  2. daniele.balducci wrote:
    > Hi All,
    > I'm generating XLS files from ASP(.Net) code using the usual


    There was no way for you to know it, but this is a classic asp newsgroup.
    While you may be lucky enough to find a dotnet-knowledgeable person here who
    can answer your question, you can eliminate the luck factor by posting your
    question to a group where those dotnet-knowledgeable people hang out. I
    suggest microsoft.public.dotnet.framework.aspnet.

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jul 4, 2005
    #2
    1. Advertising

  3. Hi Bob ,
    thanks for your quick answer .... I'll repost to that discussion
    group now.
    Anyway it's not a .net specific problem ... it also happens on pure ASP code
    .... (please note the .net in parhentesis on my original append) ... Thanks
    Daniele

    "Bob Barrows [MVP]" wrote:

    > daniele.balducci wrote:
    > > Hi All,
    > > I'm generating XLS files from ASP(.Net) code using the usual

    >
    > There was no way for you to know it, but this is a classic asp newsgroup.
    > While you may be lucky enough to find a dotnet-knowledgeable person here who
    > can answer your question, you can eliminate the luck factor by posting your
    > question to a group where those dotnet-knowledgeable people hang out. I
    > suggest microsoft.public.dotnet.framework.aspnet.
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
    >
     
    daniele.balducci, Jul 4, 2005
    #3
  4. daniele.balducci wrote:
    > Hi All,
    > I'm generating XLS files from ASP(.Net) code using the usual
    > code chunks ...
    >
    > Response.ContentType = "application/vnd.ms-excel"
    > Response.AppendHeader("Content-Disposition", "attachment;
    > filename=""" &
    >
    > NomeFile & """")
    > Response.Flush()
    > Response.write("<table border=""1"" .....
    > .....
    > .....
    > Response.end
    >
    > It all works fine since I'm able to Open/Save the file with Excel
    > 2000. But ....
    > ...... when I run the code on a box where only an Excel Viewer 2003 is
    > installed (rather then the full product)


    You mean the client machine only has the viewer installed? If so, this is a
    client-side browser issue, not ASP.

    > I cannot open it, and Viewer
    > aborts with the following Message : "Cannot Open files of this type".


    IIRC (hopefully someone will jump in and correct me if necessary),
    "application/vnd.ms-excel" requires Excel, not the viewer.

    > Choosing to save save the file to reopen it laterleads to the same
    > error.


    I don't understand this step.

    >
    > Moreover, the generated XLS file looks to be really small ....(1Kb)
    > and after opening and resaving it from Excel program as a xls
    > Workbook it becomes larger (14Kb). At this point the viewer can open
    > it.. ...
    >
    > All this let me think that the generated file is not a "real" xls
    > file .... while viewer can only open this kind of files ... (also
    > tried to use freeware viewer but I got the same behaviour .....)
    >


    You might try an Excel newsgroup to see if there is any difference

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jul 4, 2005
    #4
  5. daniele.balducci

    Roland Hall Guest

    "Bob Barrows [MVP]" wrote in message
    news:...
    : daniele.balducci wrote:
    : > Choosing to save save the file to reopen it laterleads to the same
    : > error.
    :
    : I don't understand this step.

    I think she's saying that she initially wants to call the associated app to
    open the file, when prompted with open/save to file and even if she saves to
    file first and then tries to open it with the viewer, possibly called via
    Explorer, the same error occurs, "Can not open files of this type."

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Jul 5, 2005
    #5
  6. daniele.balducci

    Roland Hall Guest

    "daniele.balducci" wrote in message
    news:...
    : Hi All,
    : I'm generating XLS files from ASP(.Net) code using the usual code
    : chunks ...
    :
    : Response.ContentType = "application/vnd.ms-excel"
    : Response.AppendHeader("Content-Disposition", "attachment; filename=""" &
    :
    : NomeFile & """")
    : Response.Flush()
    : Response.write("<table border=""1"" .....
    : .....
    : .....
    : Response.end
    :
    : It all works fine since I'm able to Open/Save the file with Excel 2000.
    But
    : ....
    : ...... when I run the code on a box where only an Excel Viewer 2003 is
    : installed (rather then the full product) I cannot open it, and Viewer
    aborts
    : with the following Message : "Cannot Open files of this type".
    : Choosing to save save the file to reopen it laterleads to the same error.
    :
    : Moreover, the generated XLS file looks to be really small ....(1Kb) and
    : after opening and resaving it from Excel program as a xls Workbook it
    becomes
    : larger (14Kb). At this point the viewer can open it.. ...
    :
    : All this let me think that the generated file is not a "real" xls file
    .....
    : while viewer can only open this kind of files ... (also tried to use
    freeware
    : viewer but I got the same behaviour .....)

    You could try a different MIME type.

    application/msexcel
    application/x-msexcel
    application/x-ms-excel
    application/vnd.ms-excel
    application/x-excel
    application/x-dos_ms_excel
    application/xls
    application/x-xls
    zz-application/zz-winassoc-xls

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Jul 5, 2005
    #6
    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. =?Utf-8?B?c21lbg==?=

    only upload *.xls files...

    =?Utf-8?B?c21lbg==?=, Jun 2, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    452
    Steve C. Orr [MVP, MCSD]
    Jun 2, 2004
  2. =?Utf-8?B?ZGFuaWVsZS5iYWxkdWNjaQ==?=

    Generating XLS files from ASP

    =?Utf-8?B?ZGFuaWVsZS5iYWxkdWNjaQ==?=, Jul 4, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    7,033
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=
    Jul 4, 2005
  3. =?Utf-8?B?c25pY2tz?=

    How to embed XLS files within PPT in an ASP.NET app

    =?Utf-8?B?c25pY2tz?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,244
    Steven Cheng[MSFT]
    Jan 23, 2006
  4. Fonzie

    downloading .xls files from the web

    Fonzie, Feb 7, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    379
    Chris Mahoney
    Feb 8, 2007
  5. Albert-jan Roskam

    newbie - merging xls files using xldt and xlwt

    Albert-jan Roskam, Oct 15, 2008, in forum: Python
    Replies:
    5
    Views:
    636
    Jules Stevenson
    Oct 23, 2008
Loading...

Share This Page