正确的 SpreadsheetML 文件扩展名

Proper SpreadsheetML file extension

我想在本地驱动器上创建一个 SpreadsheetML 文件,该文件可以在 MS Excel 中打开,或者通过在 Windows 资源管理器中单击文件打开 Office。

我尝试了所有注册到 Microsoft Excel 的文件扩展名。 其中一些(例如 .xls)允许打开文件,但在 "File is in different format than specified by the file extension" 警告对话框之后。某些扩展(如 .xlsx)导致 Excel 在不打开文件的情况下显示格式错误对话框。

Wikipedia 告诉扩展名应该是 .xml,但它被注册为默认由网络浏览器打开。

This, this and this 类似的问题是关于从网络下载文件并设置正确的内容类型。但是我无法更改本地文件的内容类型。

This 文章解释了这个烦人的扩展强化机制是如何工作的以及如何禁用它,但我认为强迫用户禁用安全功能只是为了允许打开电子表格文件是错误的。

所以没有解决办法还是我遗漏了什么?

现在 Open Office 可以打开 .xlsx(和读取)文件,Excel 可以打开(和读取).ods 文件。我的建议是选择最适合您的受众和您对特定文件格式的理解的一种。

这两个应用程序各有优缺点和不支持的功能。

我建议查看文档 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.

Open Office 有一个问题,当您保存 .xlsx 文件时,它会将格式更改为 .ods 文件。无论如何,这两个应用程序都会在保存后重新安排文件夹结构。

最大的变化是创建 SpreadsheetML 文件的方式,Open Office 和 Excel 都有不同的文件夹结构,具体取决于您将使用的文件扩展名。

这是一个 Excel 文件夹格式的简短示例。

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

我为此创建了一个示例 GitHub 存储库,其中包含一个可以在 Excel 和 Open Office 中打开的示例。

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