Hello everyone!
I'm writing here, because CellRichText() works on Python 3.8.4 for me, but not 3.9.0.
When I run my basic script
workbook = Workbook()
sheet = workbook.active
label = "koprende"
color = "#2199FF"
color = InlineFont(color=f"FF{color[1:]}") # input color format:
label_block = TextBlock(color, label)
cell_rich_content = CellRichText("Hello, ", label_block)
sheet["A2"] = cell_rich_content
sheet["A1"] = "rich below"
workbook.save(filename="testRichText.xlsx")
On Python 3.9.0 I get the following errror
File "C:\Users\User1\AppData\Local\Programs\Python\Python39\lib\site-packages\openpyxl\cell\_writer.py", line 82, in etree_write_cell
text = r.name
AttributeError: 'TextBlock' object has no attribute 'name'
I checked out the code and it seems, that when the script handles a TextBlock() element, it can't find the text inside. I tried dir(r) and didn't saw a name property, but there was text. I changed that. Tried again.
This time I got another error:
File "C:\Users\botcho\AppData\Local\Programs\Python\Python39\lib\site-packages\openpyxl\xml\functions.py", line 86, in whitespace
if node.text != node.text.strip():
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'strip'
So it turns out that here node.text isn't text exactly, but xml.etree.ElementTree.Element.
Hence the code can't get the text out and the strip() method on it.
The weird thing is, that I'm getting the same errors on versions below Python 3.8.0, but I don't understand how the later versions like 3.9.0 get the same error. I suspect it's not fault of Openpyxl, but I'd really appreciate if you can help me figure it out. If it's bug in the code, I can even take some time to fix it myself, if you want. I'm open for that.
Thanks beforehand and cheers