Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Response.ContentType = "application/ms-excel"

Reply
Thread Tools

Response.ContentType = "application/ms-excel"

 
 
jrasmussen@idealas.com
Guest
Posts: n/a
 
      10-26-2005
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

 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      10-26-2005
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

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>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
>



 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      10-26-2005
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:%(E-Mail Removed)...
> 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
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>>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
>>

>
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      10-26-2005
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...


--

<(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed) oups.com...
> 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
>



 
Reply With Quote
 
jrasmussen@idealas.com
Guest
Posts: n/a
 
      10-26-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments