Generating XLS files from ASP

  • Thread starter daniele.balducci
  • Start date
D

daniele.balducci

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
 
B

Bob Barrows [MVP]

daniele.balducci said:
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.
 
D

daniele.balducci

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
 
B

Bob Barrows [MVP]

daniele.balducci said:
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
 
R

Roland Hall

in message
: 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
 
R

Roland Hall

in message
: 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top