不知名的天某人 2019-12-24 09:24 采纳率: 0%
浏览 1317
已采纳

openpyxl 生产xlsx文件报错

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

  • 写回答

2条回答 默认 最新

  • kedoneyes 2020-03-31 17:25
    关注

    安装3.03,解决问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已采纳回答 7月27日

悬赏问题

  • ¥15 Mac虚拟机安装Windows,Windows中用idea跑项目,报错process finished with exit code -1073741819(0xc0000005) 如何解决?
  • ¥15 关于python爬虫返回js数据结构的处理
  • ¥15 ubuntu所用stm32标准库开发烧录没反映
  • ¥15 运维工程师(在职人员回答)
  • ¥15 python 爬虫问题
  • ¥15 Kmeans的趋势分析有会的吗
  • ¥20 R语言单细胞测序 对seurat对象进行标准化时出现问题
  • ¥15 Anaconda navigator updateor一直更新
  • ¥15 请问如何在matlab里使用raven工具?
  • ¥100 关于ios手游充值到一定金额,再点充值提示公众号的问题。