您好我使用循环从excel中的列中提取数据到数组中。因为我有很多数据需要一点时间。我想知道是否有办法更快地完成它?
使用功能: def xlscol(fname,sheetname,col,r1,r2):
col is a string of the column to get data from
fname is filename, col is column as a letter string, r1, r2 are row 1 to row 2, sheetname
"""
import openpyxl
wb = openpyxl.load_workbook(fname, data_only=True)
ws = wb[sheetname] #get worksheet
results =[]
for row in range(r1,r2):
for column in col:
cell_name = "{}{}".format(column, row)
results.append(ws[cell_name].value)
return results