473,396 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Exporting to Excel (xlsx files)

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
%>
Nov 19 '08 #1
1 9081
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" <dn******@dtgnet.comwrote in message
news:b4**********************************@t2g2000y qm.googlegroups.com...
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
%>

Nov 19 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
0
by: Arunkumar subramanian | last post by:
Hi, I am facing a problem with export to excel. I am having a template xlsx file, in the process i am unzipping that in to a folder and pushing my data in to sheet1.xml. then zipping it back...
0
by: MBlock316 | last post by:
Hello everyone, I am trying to import a Microsoft Excel 2007 formatted file into my application. I found on another thread in another forum that I needed to install the 2007 Office System Driver:...
1
by: MBlock316 | last post by:
Hello everyone, I am trying to import a Microsoft Excel 2007 formatted file into my application. I found on another thread in another forum that I needed to install the 2007 Office System Driver:...
4
by: =?Utf-8?B?THluZXJz?= | last post by:
Hello All, We have a VB.NET application writen using VS 2003. This application apens an excel file from a vendor, reads the data and performs whatever functions it needs. We recently upgraded our...
20
by: Marin Brkic | last post by:
Hello all, please, let me apologize in advance. English is not my first language (not even my second one), so excuse any errors with which I'm about to embarass myself in front of the general...
8
by: K Viltersten | last post by:
I understand that the new versions of MS Word, MS Excel etc. allow for creation of a document using XML tags (the technique or format is called OOXML, i think). I imagine that the idea behind...
5
by: Doogie | last post by:
Can anoyne tell me why this VBScript will create the file to Excel just fine, but the Excel file will not open up? I am saving it as a xlsx file instead of an xls one and I have the new version of...
1
by: Doogie | last post by:
Can anoyne tell me why this VBScript will create the file to Excel just fine, but the Excel file will not open up? I am saving it as a xlsx file instead of an xls one and I have the new version of...
8
blazedaces
by: blazedaces | last post by:
So I have a program below which writes an excel file with multiple sheets based on inputs of sheet names, data, cell types, etc. It uses Apache POI, which is currently the only thing I found...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.