Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Exporting to Excel (xlsx files)

Reply
Thread Tools

Exporting to Excel (xlsx files)

 
 
Doogie
Guest
Posts: n/a
 
      11-19-2008
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
%>
 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      11-19-2008
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






"Doogie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
> %>



 
Reply With Quote
 
 
 
 
Semio Semio
Guest
Posts: n/a
 
      12-23-2008
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
 
Reply With Quote
 
Neil
Guest
Posts: n/a
 
      03-16-2009


"Mark Rae [MVP]" wrote:

> "Semio Semio" wrote in message news:(E-Mail Removed)...
>
> > Do you known the difference between ASP.Net & ASP Classic?

>
> He does - do you...?
>
> > This is ASP.NEt Inline code..

>
> No it's not - it's ASP Classic.
>
> > 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 choice but sometimes useful!

>
> That's correct, but irrelevant in this case...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>

Looks like vb script to me...

 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting to Excel using new version of Excel Doogie ASP .Net 1 11-19-2008 09:10 PM
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= ASP .Net 15 10-24-2007 01:34 PM
Exporting the datagrid to excel, text and html files. Ravindra ASP .Net 0 12-14-2005 04:14 AM
exporting an excel file from database; making changes to excel file and updating the database by importing it back Luis Esteban Valencia ASP .Net 1 01-12-2005 12:28 AM
Re: Exporting to Excel using CSS Marshal Antony ASP .Net 1 01-12-2004 09:19 PM



Advertisments