导入BarChart的语法错误,Python-IDLE中的参考。 vs代码中没有错误,并且没有输出就停止

时间:2019-04-01 18:12:30

标签: python

我正在一个小项目上更新EXCEL(xlsx)文件中的数据,并且运行良好,但是当我尝试绘制图表时,它停止在vs代码中工作,而在python-3.7中,它说在bar-附近出现语法错误图表

像往常一样搜索堆栈溢出:)

import openpyxl as xl
import openpyxl.chart import BarChart, Reference #Here the problem


wb = xl.load_workbook('transactions.xlsx')
sheet = wb['Sheet1']
cell = sheet['a1'] #column a and row 1
cell = sheet.cell(1,1) # same job as above line does

for row in range(2, sheet.max_row + 1): #because at row 1 all the values r 
cell = sheet.cell(row,3)             #column names we don't want to modify
corrected_price = cell.value * .9
corrected_price_cell = sheet.cell(row, 4)                          
corrected_price_cell.value = corrected_price

values = Reference(sheet, min_row = 2, max_row = sheet.max_row, 
min_col = 4, max_col = 4)

chart = BarChart() # from here the problem starts
chart.add_data(values)
sheet.add_chart(chart, 'e2') #e2 to get only the values in that column

wb.save('transactions2.xlsx')

预计会绘制图表,但它会停止工作

0 个答案:

没有答案