Skip to content
Advertisement

How to write German umlauts to a spreadsheet with xlsxwriter in Python

I already tried this one, but when I open the Excel spreadsheet, the whole Excel file is blank. Is there another way?

JavaScript

Advertisement

Answer

Excel, and XlsxWriter, use either ASCII or UTF-8. To write a string like that in Python 2:

  1. Encode the file as UTF-8.
  2. Include the “coding” directive at the start of the file.
  3. Use u” to indicate a Unicode string.

Like this:

JavaScript

enter image description here

In Python 3 you just need to encode the file as UTF-8.

See the Unicode examples in XlsxWriter docs.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement