Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple styles in one cell in openpyxl

I wrote a Python program which produces invoices in a specific form as .xlsx files using openpyxl. I have the general invoice form as an Excel workbook and my program copies this form and fills up the details about the specific client (eg. client refernce number, price, etc.) which are read from another .txt file.

The program works perfectly. The only problem is that the form contains a cell which has multiple styles: half of the letters are red and the rest black and there is also size difference. This cell is not edited in my program (it is the same in all the invoices), however after the rest worksheet is edited by my program the cell keeps only the first style (the red letters).

Why does openpyxl changes this cell since I don't edit it? Does openpyxl support multiple styles, or I have to split the letters with different styles in seperate cells?

like image 319
Stealth Avatar asked Nov 23 '25 18:11

Stealth


1 Answers

openpyxl does not support multiple styles within an individual cell.

like image 71
Charlie Clark Avatar answered Nov 26 '25 08:11

Charlie Clark