tags:

views:

707

answers:

5

I have an Excel file in OfficeML format, MyData.xls. Since I upgraded to Office 2007 from Office 2003 I get a warning message saying that the file content does not match the file extension. It seems that OfficeML now must have the extension 'xml'.

In my application I use OleClientSite to display the file in an OleFrame object. If I change the file extension to 'xml' then Excel is not started. If I leave the extension as 'xsl' then I get the above warning message.

How can I force the file with the 'xml' extension to be opened in the OleFrame using Excel?

+1  A: 

Maybe I'm missing something, but shouldn't you just use .xslx as your extension? I'm assuming that by OfficeML, you're refering to Office Open XML.

Eclipse
I don't know - I've tried so many variations. I think though that xls and xlsx are binary formats and if I save a sheet in OfficeML Excel uses the 'xml' extension.
paul
xlsx files are a bunch of xml files zipped up together, so it's kind of a mix between text and binary.
Eclipse
Josh: sure, but the issue is that I have OfficeML content and just giving that an xlsx file extension is going to cause that warning message I mentioned about the content not matching the file type. The warning is making my users worried about opening the file and I want to avoid it without having to create real xls or xlsx files.
paul
+2  A: 

The easiest solution is to switch back to the 2003 format, which should not require any changes to your application. To do this, open your file with the extension set to *.xls. When prompted with the warning ("... do you want to open the file now?"), proceed to open (this is a warning to make sure you don't unintentionally open a macro-enabled file). Once in Excel and the file is open, simply save it as *.xls. This can be done by going to "Office Button / Save As / Excel 97-2003 Workbook".

Now, the harder solution will be upgrading your application to deal with the new OfficeML format. I don't know about the component you're using, but it will likely still work for some of the binary parts in the new standard (most notably VBA projects), but you're going to have to unpack and start reading XML files.

If you haven't already done this, create a new Excel workbook, save it as *.xlsx (the 2007 format) and in Explorer, change its extension to *.zip. Open it up and take a look around. For more in-depth on the files, I would start digesting this MSDN article.

TimS
Tim: the content is being generated programmatically and OfficeML is a nice (and easy) way to create Office docs. The security warning is worrying my users and I want to avoid that.
paul
Ah, I see! So, the question is what file is really being output from your app? My hunch is that it is the older Office 2003 XML Spreadsheet format (*.xml). Can you open your file in notepad? If so, what are the first few lines? A 2003 XML file (with the *.xml ext) would open properly from explorer (as the opening app is defined in the XML as <?mso-application progid="Excel.Sheet"?>. Can you verify this?
TimS
Tim: yes the <?mso-application progid="Excel.Sheet"?> node is present
paul
Well, I'm not sure how you're opening the file, but that node should dictate to the OS what app to open. Can you use automation, create an XL app object and force Excel to open it (xlApp.Open(file)? Ultimately you should consider updating your app to output to the new 2007 Open Office XML format. There's an interesting post here at stackoverflow that might help: http://stackoverflow.com/questions/591463/convert-excel-2003-xml-file-to-excel-2003-xls-format
TimS
+1  A: 

Hi Paul,

Unfortunately I don't have enough 'reputation' to comment so I have to resort to an 'answer'... even though I don't have one for you.

If you're still monitoring this question - I'd like to know if you found a solution. I have the same issue at present. Fortunately my user base will be 2003 for the time being (as far as I'm aware - they're in Australia and I'm in Ireland!). I'm sure it's a matter of time before they upgrade to 2007, at which point I'll have the same issue.

Let me know either way - I'll keep looking too.

Sean
Sorry, no progress so far. I look forward to getting your 'real' answer ;-)
paul
I'll keep looking - though I have a feeling it's a built-in security mechanism in 2007...Tell me - were you able to get the AutoFitHeight to work? I have it set to 1 and have a minimum height set, also set the cell with the long text's wrapping on - but the height never auto adjusts.If you haven't used this functionality, I'll post a question.
Sean
A: 

Hi

This post is old but

I have the same problem,

Does anyone find an issue for this problem?

Avoid the warning message when, we use a file with ".xls" extension but it is not a xls file. (it is a html or xml file)

yours sincerely

Cebb13
A: 

I have a problem with this too...

I am working with OLEClientSite to open a frame with MS Office on my application.

However, I have a file originally created in MS Office 2003. If I open it by SWT and a machine with MS Office 2007, edit and save for my OLEClient he saved with the extension doc, however, the content is in standard docx.

I can not open this document on a machine with Office 2003.

If I do the same process using Office 2003 and Office 2003 works. If I do the same process using Office 2007 and Office 2007 works well.

The problem occurs from one version to another in doc file format.

I would like some help. Thank you.