用python复制粘贴单元格

2024-04-30 04:17:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将单元格值从一个工作簿复制到另一个工作簿。我需要从第2页复制单元格A1、A2、B4、B5、B6、B7,并粘贴到单元格A1、B1、C1、D1、E1、F1中的新工作簿中。 我怎么能用python做到这一点?

import xlrd
file_location = "C:/attach/Source.xlsx"
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(1)

for row in range(sheet.nrows):
    cell = sheet.cell(row, 1)
print(cell.value)

Tags: a2粘贴a1celllocationb1filesheet