Response.ContentType = "application/ms-excel"

J

jrasmussen

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
 
R

Ray Costanzo [MVP]

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
 
R

Ray Costanzo [MVP]

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
 
J

jrasmussen

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
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top