python 3.6 openpyxl 3.0.2
from openpyxl import Workbook
from openpyxl.utils import get_column_letter
wb = Workbook()
dest_filename = 'empty_book.xlsx'
ws1 = wb.active
ws1.title = "range names"
for row in range(1, 40):
ws1.append(range(600))
ws2 = wb.create_sheet(title="Pi")
ws2['F5'] = 3.14
ws3 = wb.create_sheet(title="Data")
for row in range(10, 20):
for col in range(27, 54):
_ = ws3.cell(column=col, row=row, value="{0}".format(get_column_letter(col)))
print(ws3['AA10'].value)
wb.save(filename = dest_filename)
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/python 报价单生成脚本/111.py", line 36, in
wb.save(filename = dest_filename)
File "D:\Anaconda3\lib\site-packages\openpyxl\workbook\workbook.py", line 408, in save
save_workbook(self, filename)
File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 293, in save_workbook
writer.save()
File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 275, in save
self.write_data()
File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 75, in write_data
self._write_worksheets()
File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 215, in _write_worksheets
self.write_worksheet(ws)
File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 200, in write_worksheet
writer.write()
File "D:\Anaconda3\lib\site-packages\openpyxl\worksheet_writer.py", line 354, in write
self.write_top()
File "D:\Anaconda3\lib\site-packages\openpyxl\worksheet_writer.py", line 98, in write_top
self.write_properties()
File "D:\Anaconda3\lib\site-packages\openpyxl\worksheet_writer.py", line 60, in write_properties
self.xf.send(props.to_tree())
File "D:\Anaconda3\lib\site-packages\openpyxl\worksheet_writer.py", line 294, in get_stream
xf.write(el)
File "src/lxml/serializer.pxi", line 1230, in lxml.etree._IncrementalFileWriter.write
TypeError: got invalid input value of type , expected string or Element