Solved

Classic ASP, Microsoft Excel 2007

Posted on 2011-03-03
8
3,010 Views
Last Modified: 2012-05-11
Hi, I am writing a script to export data to an excel file which works
fine but it gives me warning:

"The file you are trying to open, 'ABC.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening. Do you want to open file now?"

If I use the extension .xlsx, the file will get created, but Excel won't let me
open it. I get an error:
"Excel cannot open the file "ABC.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".

With .xls, I can open file with warning and with .xlsx, I can't open the file.
It'll be really helpful if you help me get rid of that warning.

I am using classic ASP and Microsoft Office 2007.


Thank you.



0
Comment
Question by:pawar_deepak
8 Comments
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 35031517
I *think* you can find a solution from this link:

http://www.eggheadcafe.com/community/aspnet/2/10051034/problem-when-opening-a-excel-file-wrtten-using-c-net-code.aspx

Please let me know if none of the solutions help you.
0
 
LVL 7

Expert Comment

by:hippohood
ID: 35041012
Hi

It is not clear to me if you are getting this error when script tries open the file or or when you are trying to open an Excel file created by script?

without seen what your script is doing it is difficult to say, but, apparenty, your script assumes a wrong file formats/types. XLS extension is used for 97-2003 workbboks versions.

For 2007+ version they have several types for this: XLSX is for no-macro workbooks (which are, in reality, a XML text file compressed with ZIP), XLSM is a macro-enabled workbook and XLSB is a binary file, most similar to XLS.

Most likely, your file should has XLSM extension, and the Excel warns you that you are opening a file, which may be hazardous. Try using XLSM extension and add the file location to Trusted Sources.
0
 
LVL 14

Accepted Solution

by:
Zack Barresse earned 500 total points
ID: 35053916
When you create the file, are you using the new file format extensions?  Take a look at Ron de Bruin's site for examples on saving 2007+ files...

http://www.rondebruin.nl/saveas.htm

Zack
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 14

Expert Comment

by:Zack Barresse
ID: 35318053
It seems it's another file format issue, which should be resolved if they specify the particular file format in their code.  The link to Ron de Bruin's site has it well documented, and should have worked for them.  I don't care about the points, but I disagree that it should be deleted as I've provided the solution.

Zack
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 35318823
I too could care less about the points but what gets me with the recommendation is that the poster never actually responded to any of the solutions posted.

So, I am not real sure why the decision to delete.

Either way, refund him his points but please encourage them to respond to solutions so we know whether or not the solutions we suggest has helped them or not.
0
 
LVL 1

Expert Comment

by:modus_operandi
ID: 35357068
Starting auto-close process to implement the recommendations of the participating Expert(s).
 
modus_operandi
EE Admin
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question