Link to home
Start Free TrialLog in
Avatar of pawar_deepak
pawar_deepakFlag for United States of America

asked on

Classic ASP, Microsoft Excel 2007

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.



Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

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.
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.
ASKER CERTIFIED SOLUTION
Avatar of Zack Barresse
Zack Barresse
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
Avatar of modus_operandi
modus_operandi

Starting auto-close process to implement the recommendations of the participating Expert(s).
 
modus_operandi
EE Admin