openpyxl处理两个excel,复制excel中的一列到另外一个excel中,这里只处理了表格中的第一列

import os
import openpyxl
from test_decode import decrypt




wb = openpyxl.load_workbook(r'C:\Users\chenchi\Documents\base_userinfo.xlsx')
print("excel have been opened")
sheet = wb['base_userinfo']  # 获取指定sheet表
print(sheet)
#cell1 = sheet['A']
#print(type(cell1))

# cell = sheet.cell(row=1, column=1)
# print(cell.value)



workbook2 = openpyxl.load_workbook(r'C:\Users\chenchi\Documents\base_user2.xlsx')  # 返回一个workbook数据类型的值
sheet2 = workbook2.active  # 获取活动表
print('当前活动表是:' + str(sheet2))

for i in range(1,150000):
    #这里只处理了表格中的第一列
    cell = sheet.cell(row=i, column=1)
    #print(cell.value)
    cellxx=decrypt(cell.value)
    print(cellxx)
    #print(cellxx.value)
    #数据插入表格,row表格中的行,column,
    sheet2.cell(row=i, column=1, value=cellxx)

workbook2.save(r'C:\Users\chenchi\Documents\base_user2.xlsx')
workbook2.close()
wb.close()

你可能感兴趣的:(前端,linux,javascript)