我有一张包含数据的 Excel 表:
当我尝试创建这样的图表时 [群集图表]
openpyxl 无法正确读取数据
from openpyxl.chart import BarChart, Reference
from openpyxl import load_workbook, workbook
wb = load_workbook("Book1.xlsx")
ws = wb.active
data = Reference(ws, min_col=2, min_row=1, max_row=12,max_col=7)
categories = Reference(ws, min_col=1, min_row=3, max_row=12)
barChart = BarChart()
barChart.type = "col"
barChart.grouping = "clustered"
barChart.title = "XYZ"
barChart.y_axis.title = "service"
barChart.x_axis.title = "month"
barChart.add_data(data,titles_from_data=True)
barChart.set_categories(categories,labels="dasd")
barChart.style = 5
barChart.width = 20
barChart.height = 10
ws.add_chart(barChart,"k8")
wb.save("test.xlsx")
我尝试取消合并标题,但是,如果我这样做,我想要的图表将不会被创建。
我尝试了所有组合,但 openpyxl 就是不能正确捕获数据