range写入数据时选择写入位置语句错误

问题描述

想在一个文件的最后一列插入数据,我的思路是读取文件的列数,然后插入数据。

代码如下:


ncol= result_sh.shape[1]  #获取列数

result_sh.range(3,ncol).options(transpose=True).value = result_data

其中range(3,ncol)中的ncol字符提示是错误的,加了引号也无法运行,请问下有什么解决方法么?

用单元格地址试下:range(ncol+'3')

https://www.cnblogs.com/techtalk/articles/10590212.html

LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def getRange(row, col):    
    result = []
    while col:
        col, rem = divmod(col-1, 26)
        result[:0] = LETTERS[rem]
    return ''.join(result) + str(row)