简体   繁体   English

Openpyxl 无法加载带有散点图的工作簿(类型错误:预期<class 'openpyxl.chart.axis.NumericAxis'> )

[英]Openpyxl unable to load workbook with Scatter Chart (TypeError: expected <class 'openpyxl.chart.axis.NumericAxis'>)

With reference to this , I want to modify certain cell values instead of reading it only.参考这个,我想修改某些单元格值而不是只读取它。

wb = load_workbook('example.xlsx')
ws = wb["Sheet1"]

ws['B3'] = "it works"

wb.save('example.xlsx')

Error:错误:

TypeError: expected <class 'openpyxl.chart.axis.NumericAxis'>

The sheet I am trying to modify does not contain any charts hence, I am trying to find a workaround for this where I only load that one sheet for updating some cell values.我试图修改的工作表不包含任何图表,因此,我试图找到一种解决方法,我只加载该工作表以更新某些单元格值。

Although one workaround would be to separate the charts into another excel file and link it via file references, this would be less "clean" especially since the charts are meant to be grouped together with the data in one file.尽管一种解决方法是将图表分离到另一个 Excel 文件中并通过文件引用链接它,但这会不太“干净”,尤其是因为图表旨在与一个文件中的数据组合在一起。

Any help would be appreciated.任何帮助,将不胜感激。

解决办法是降级openpyxl版本< 2.5.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM