ValueError: {0} is not a valid coordinate or range问题解决

获取excel多列方法:

>>> colC = ws['C']
>>> col_range = ws['C:D']

采用python 实现时,开始列与结束列采用变量传入:
sheetgenerator=work_sheet["'"+start_col+":"+end_col+"'"]
执行以上方法时报错:ValueError: {0} is not a valid coordinate or range

解决办法:正确的方法,只需将“:”转换为字符串即可
sheetgenerator=work_sheet[start_col+":"+end_col]

posted @ 2018-09-20 14:43  垄上行  阅读(5212)  评论(0编辑  收藏  举报