读取单元格值python

时间:2017-07-21 09:22:24

标签: python openpyxl xlrd

我使用下面的代码来读取excel,是否可以只读单元格" C13"或" A9"

file = self.excel_file.decode('base64')

excel_fileobj = TemporaryFile('wb+')
excel_fileobj.write(file)
excel_fileobj.seek(0)

workbook = openpyxl.load_workbook(excel_fileobj, data_only=True)

sheet = workbook[workbook.get_sheet_names()[0]]

for row in sheet.rows:
            print(row[1].value)

1 个答案:

答案 0 :(得分:3)

你试过了吗?

print(str(sheet['C13'].value))
print(str(sheet['A9'].value))