sheet.write(7, 1, '=SUM(B5:B7)') sheet.write(7, 2, '=SUM(C5:C7)')求和公式输出为0
sheet = wb.add_worksheet("newsheet") sheet.merge_range(0, 0, 0, 2, "2020年度", cell_format1) sheet.merge_range(1, 0, 2, 2, "第一季度销售统计", cell_format2) sheet.write_row(3, 0, ["月份", "预期销售额", "实际销售额"]) data = ( ["一月份", 400, 350], ["二月份", 500, 450], ["三月份", 470, 750] ) for index, item in enumerate(data): sheet.write_row(index + 4, 0, item, cell_format) # 求和 sheet.write(7, 1, '=SUM(B5:B7)') sheet.write(7, 2, '=SUM(C5:C7)')
wb.close()