# pip install xlutils
import xlrd
import xlutils
from xlutils.copy import copy
# 打开excel
read_book = xlrd.open_workbook('./办公自动化/files/电影.xls')
# 复制数据
wb = copy(read_book)
# 选择工作簿
sh = wb.get_sheet(0)
sh.write(6, 0, '流浪地球')
sh.write(6, 1, 46.81)
# 增加一个工作簿
sh2 = wb.add_sheet('汇总')
count = 0
rs = read_book.sheet_by_index(0)
for i in range(1, rs.nrows):
num = rs.cell_value(i, 1)
count += num
sh2.write(0, 0, '总票房')
sh2.write(0, 1, count)
wb.save('./办公自动化/files/电影2.xls')