问题描述:
设置excel单元格百分比格式为数字老是不生效
sheet.cell(row=1, column=5).number_format = '0.00%'
修改代码给该单元格赋值的语句
原代码:
sheet.cell(row=1, column=5).value = '{:.2%}'.format(float(item['this_week_p2_bug']) / float(item['this_week_total_bug']))
修改后代码:
sheet.cell(row=1, column=5).value = round(float(item['this_week_p1_bug']) / float(item['this_week_total_bug']), 2) 成功