如何阅读OpenPyXl中的条形图?
我有一个Excel文件,该文件的条形图(Chart2)为“输出”的表格。因此,我想使用OpenPyXl更改Chart2的样式格式。但是,我尝试了不适合我的简单代码:
from openpyxl import load_workbook
from openpyxl.chart import BarChart, Series, Reference
wb = load_workbook(r'C:\Users\sma.xlsx')
sheet1 = wb['Output']
Chart2 = BarChart()
print(Chart2)
Chart2.style = 6
wb.save(r'r'C:\Users\sma.xlsx')
wb.close()
有人可以给我正确的方法来获得正确的结果吗?
I have an excel file that has a Bar Chart (Chart2) as a sheet named 'Output'. So I want to change the style format of Chart2 by using Openpyxl. However, I tried the simple code that did not work for me:
from openpyxl import load_workbook
from openpyxl.chart import BarChart, Series, Reference
wb = load_workbook(r'C:\Users\sma.xlsx')
sheet1 = wb['Output']
Chart2 = BarChart()
print(Chart2)
Chart2.style = 6
wb.save(r'r'C:\Users\sma.xlsx')
wb.close()
Can anyone give me the right approach to get my proper result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论