[QGIS-Developer] Loading many Excel-Files in QGIS with correct encoding

Andrea Giudiceandrea andreaerdna at libero.it
Thu Jul 15 11:51:51 PDT 2021


> Isn't this limitation ultimately that GDAL isn't reading the encoding
> correctly? (Or perhaps it's a limitation in the underlying freexl
> library...)
> 
> Nyall


Hi Nyall and Andreas,
it seems to me GDAL/OGR [1] reads XLS and XLSX files with the relative 
proper encoding [2] and ogrinfo outputs the text in UTF-8 for both the 
formats.

Instead, QGIS imports correctly XLSX files as UTF-8 encoded, while XLS 
files are wrongly imported as "system" encoded, even selecting UTF-8 [3] 
encoding in the Data Source Manager vector import window.

After importing a XLS file, changing the "Data source encoding" of the 
layer to "UTF-8" fixes the text codecs in my tests.

So, I think QGIS should automatically import also XLS files as UTF-8 
encoded.

Best regards.

Andrea Giudiceandrea

[1] tested on Windows /OSGeo4W: GDAL 3.1.4 / FreeXL 1.0.2 / Expat 2.1.0 
and GDAL 3.2.2 / FreeXL 1.0.6 / Expat 2.2.10
[2] text in XLS (BIFF8) files are internally encoded in UTF-16LE
[3] by the way, there are incorrectly two "UTF-8" codecs listed in the 
"Encoding" drop down menu list...


More information about the QGIS-Developer mailing list