Problem with text encoding of Excel file generated by script

Dear Sirs.

I’m trying to generate an Excel file with report at the end of the process. I’m using Python and XlsxWriter module.

The problem that I encountered is that when I run the script directly from any IDE the encoding is proper:
image

However when I run the same script from Workflow process encoding of texts is wrong:
image

I tried several tricks found in google like using encode() function, changing locale with setlocale() or following these recommendation: excel - How to write German umlauts to a spreadsheet with xlsxwriter in Python - Stack Overflow but nothing worked for me. When I checked both
sys.getdefaultencoding() and locale.getlocale() both from IDE and Workflow they show the same values:
utf-8 and (‘Polish_Poland’, ‘1252’).

Did anyone encountered similar problem? I’m slowly getting out of ideas at the moment.

Best regards,
Piotr Mioduszewski

how you’re running the python code in Workflow, using the Run Script plugin?

What python version you’re using?

Did you try also with the External Program plugin by calling python.exe?

To answer the questions:

  • Script is run using Run Script plugin.
  • I’m using Python 3.8.10.
  • Yes, later I tried to use External Program plugin and in this case everything works fine.

It seems that Workflow has problems with reading strings, which are entered directly in code in py file specified as the script to run in Run Script properties. If this file reads more strings from another py file, or from some other resource like database, those strings are displayed correctly.

I suspect, that Workflow reads the first py file using wrong encoding, hence wrong characters, but all later files are read by Python interpreter itself, which handles UTF-8 encoding correctly.

I think it’s just because Workflow isn’t UTF-8 capable.
So best to run it as an external program rather than using the Run Script plugin.