赞
踩
- from openpyxl import load_workbook, Workbook
-
- # data_only=True 通过这个属性的设置。可以只读取数据
-
-
- def create_excel():
- path = 'E:/Python/Poject1/V.xlsx'
- wb = load_workbook(path, data_only=True)
- sh = wb.active
- title = ['姓名', '职位', '社保', '奖金', '工资', '扣这扣那']
- # 按行数获取第一行
- for id, row in enumerate(sh.rows):
- if id == 0:
- continue
- else:
- temp_wb = Workbook()
- temp_sh = temp_wb.active
- row_data = [cell.value for cell in row]
- temp_sh.append(title) # 第一行使用title
- temp_sh.append(row_data)
- temp_wb.save(f"{row_data[1]}.xlsx")
-
-
- create_excel()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。