'xml.etree.ElementTree.Element' object has no attribute 'strip' RichText

488 views
Skip to first unread message

Chichko Liobopitko

unread,
Apr 18, 2022, 11:25:27 AM4/18/22
to openpyxl-users
Hello,
I have error, that doesn't let me save the excel file, at the end of my Python program.

Here is some code:

import openpyxl
from openpyxl import Workbook
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
from openpyxl.cell.text import InlineFont
from openpyxl.cell.rich_text import *
from time import sleep
workbook = Workbook()
sheet = workbook.active

bold = Font(bold=True)
inl_bold = InlineFont(bold)

sheet.cell(row=1, column=2).value = CellRichText(["Ok", TextBlock(inl_bold, "I say"), "Hello"])

output_file = 'test.xlsx' # output: 'date_time...pr.ID'

workbook.save(filename=output_file)


This is the whole code. I couldn't found the docs on this, so I went into the files to take a 
look and I wrote this code. I might be assigning something in the wrong order. I'm not really sure. Please, help if you can.

Chichko Liobopitko

unread,
Apr 19, 2022, 2:53:08 PM4/19/22
to openpyxl-users
I found what was causing it.

I use PyCharm to edit my code and it seems, that the built-in console does something with the win Temp folder, so I got [WinError 32] and the error in the title.
I'm not sure what causes this.

The solution is, to just compile it from somewhere. CMD works.
Reply all
Reply to author
Forward
0 new messages