Exporting to Excel (xlsx files)

D

Doogie

Hi, I am writing a script to export data to an excel file which works
fine but I've seen one thing that is confusing. If I use the
extension .xlsx, the file will get created, but Excel won't let me
open it (although I have the new version of Office in my machine and
have opened other .xlsx files before). If I save it as .xls it saves/
opens just fine.

The error I get is "Excel cannot open the file "SomeFileName.xlsx"
because the file format or file extension is not valid. Verify that
the file has not been corrupted and that the file extension matches
the format of the file".

Does anyone know why this is occurring?

<%@ Language=VBScript %>
<%
dim Cn,Rs
set Cn=server.createobject("ADODB.connection")
set Rs=server.createobject("ADODB.recordset")
Cn.open "Our Connection String"
Rs.open "A sql query",Cn,1,3
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;
filename=SomeFileName.xlsx"

if Rs.eof <> true then
response.write "<table border=1>"
while not Rs.eof
response.write "<tr><td>" & Rs.fields("Some Field") & "</td></tr>"
Rs.movenext
wend
response.write "</table>"
end if

set rs=nothing
Cn.close
%>
 
S

sloan

This is a newsgroup for asp.NET , not "classic" asp.

..........

You'll find better luck in another newsgroup.

Maybe this one:
microsoft.public.inetserver.asp.general
 
S

Semio Semio

Sloan,

Do you known the diff between ASP.Net & Classic one !!!

This is ASP.NEt Inline code.. it's not mandatory
to have the .vb class file to make .Net code !
You can always use the <% %> tag. May be not
a good chose but sometime useful !

Semio
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top