Writing multi-line strings to cells using xlwt module

后端 未结 3 1110
后悔当初
后悔当初 2020-12-31 02:32

Python: Is there a way to write multi-line strings into an excel cell with just the xlwt module? (I saw answers suggesting use of openpyxl module)

The sheet.w

3条回答
  •  佛祖请我去吃肉
    2020-12-31 02:38

    There are a few things you could try:

    1. Windows handles new lines differently to Unix/Linux. While \n (line feed) character is the standard Unix method and also used in Python, Windows requires a carriage return and line feed. You could therefore try replacing \n with \r\n.
    2. If this does not work then try replacing them with the ascii characters {chr(13) and chr(10)} inside a formula.
    3. If this still doesn't work then it may be worth trying this article which suggests a rather more long winded way of approaching the problem.

提交回复
热议问题