Search code examples
excelutf-8xlsxxls

How does Microsoft Excel detect encoding of .xls or .xlsx files?


Sometimes Excel fails to open .xls or .xlsx files with UTF-8 with right encoding and I couldn't find any encoding settings for a particular file when writing. How does Microsoft Excel detect encoding of .xls or .xlsx files?


Solution

  • Up to now, my research is:

    .xls format is used for Office 97 to Office 2003(inclusive), called BIFF8 format. The text data inside is always encoded as UTF-16. So when Excel 97 opens an .xls file, no detecting is needed.

    .xlsx format is used for beyond 2003 and is an XML format. I'm not sure if specifying encoding at top XML level is valid to Excel or has any significance.