CellRichText not rendering all Inline fonts on output - Excel 2019
The issue was firstly occured when I put the following lines in my own code:
red=InlineFont(color="FFFF0000")#includes alpha channel, cause if you put FF0000 the code translate this to 00FF0000 which is transparent
blue=InlineFont(color="FF0000FF")
sheet['B1'] = CellRichText(TextBlock(blue,'TextA\n'),TextBlock(red, 'TextB'))
Initially there was an error where it did not even accept RichText where I traced the issue and fixed it in _writer.py
. Here is the modified code:
def etree_write_cell(xf, worksheet, cell, styled=None):
...
if cell.data_type == 's':
inline_string = SubElement(el, 'is')
if isinstance(value, str):
text_element = SubElement(inline_string, 't')
text_element.text = value
whitespace(text_element)
else:
print(type(value))
for r in value:
se = SubElement(inline_string, 'r')
if isinstance(r, TextBlock):
s2 = SubElement(se, 'rPr')
s2.append(r.font.to_tree())
text_value = r.text #Changed this
else:
text_value = r
text_element = SubElement(se, 't') #Changed this
text_element.text = text_value #Changed this
whitespace(text_element) #changed variable here
else:
...
But still the color is not rendered in the worksheet. I tried version 3.2.01b as well but that does not work either. So to recap all the values are parsed correctly in the XML object I think but only the color (e.g red FFFF0000 including alpha channel in front) is not rendered on the output.
Edited by BlueSmoke