13

I want to create a a SpreadsheetML file on local drive which can be opened in MS Excel or Open Office by clicking on file in Windows Explorer.

I tried all filename extensions registered to Microsoft Excel i could find so far. Some of them (.xls for example) allows file to be opened, but after "File is in different format than specified by the file extension" warning dialog. Some extensions (like .xlsx) causes Excel to show format error dialog without opening file.

Wikipedia tells that extension should be .xml, but it is registered to be opened by web browser by default.

This, this and this similar questions are about downloading a file from web and setting proper content-type. But i can not change content-type for local file.

This article explains how this annoying Extension Hardening mechanism works and how to disable it, but i think it is wrong to force user to disable security features just to allow spreadsheet file to be opened.

So there is no solution or am i missing something?

Community
  • 1
  • 1
Vasily Redkin
  • 584
  • 1
  • 3
  • 17
  • I cant believe no one has answered :/ – tomdemuyt Aug 17 '16 at 18:17
  • With SpreadsheetML there's more to it than just renaming the file extension. .xlsx files are actually zipped files that contain several .xml files (only one of which is a SpreadsheetML file). Have you tried leaving the .xml extension (as per Wikipedia) but zipping the file and then renaming the zip file's extension to .xlsx? You might want to save a simple spreadsheet from Excel and use an unzip tool to look at how the zip is structured (the one answer here seems to be hinting at this structure). – neuronaut Aug 24 '16 at 17:58

1 Answers1

3

Now Open Office can open .xlsx (and read) files and Excel can open (and read) .ods files. My suggestion is to pick one of them that best suits your audience and your understanding of the specific file format.

Both of the applications have advantages and disadvanges and non-supported features between the two of them.

I suggest reviewing the document Differences between the OpenDocument Spreadsheet (.ods) format and the Excel (.xlsx) format.

When you work with two file formats, like .xlsx and .ods, there might be formatting differences, and not all features will be available. You’ll be able to convert data and content, but the way you work with the content might be different depending on which formats you use.

One gotcha is with Open Office when you save a .xlsx file it will change the format to a .ods file. Both the applications will re-arrange the folder structure after saving anyway.

The biggest change is how you go about creating the SpreadsheetML files, both Open Office and Excel have a different folder structure depending on the file extension you will use.

Here is a short example of an Excel folder format.

-/
 - _rels/
   - .rels
 - xl/
   - _rels/
     - workbook.xml.rels
   - sheet1.xml
   - workbook.xml
 - [Content_Types].xml

I have created a sample GitHub repository for this with a sample that will open in both Excel and Open Office.

https://github.com/Nico-StackOverflow/proper-spreadsheetml-file-extension

Nico
  • 12,493
  • 5
  • 42
  • 62