Mac代码,windows未知
import sys, openpyxl
wb = openpyxl.load_workbook('/Users/dangdang/chengfangTemple.xlsx')
sheet = wb.active
nwb = openpyxl.Workbook()
sheet2 = nwb.active
x = sys.argv[1] # 几行开始空
y = sys.argv[2] # 空几行
z = sys.argv[3] # 新文件名
for i in range(1, int(x)):
for j in range(1, sheet.max_column + 1):
sheet2.cell(row=i, column=j).value = sheet.cell(row=i, column=j).value
for i in range(int(x), sheet.max_row):
for j in range(1, sheet.max_column):
sheet2.cell(row=(i + int(y) + 1), column=j).value = sheet.cell(row=i, column=j)
nwb.save(z)
打开终端,输入‘python3空格代码名称.py空格第几行开始空空格空几行空格新文件名’