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
%>
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
%>