?
Solved

Classic ASP, Microsoft Excel 2007

Posted on 2011-03-03
8
Medium Priority
?
3,166 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
6 Comments
 
LVL 29

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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 29

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

864 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