我试图向excel中的命名表中添加数据,但我不知道如何向命名excel表中添加其他行,因为openpyxl文档对这个包的功能没有帮助。到目前为止,我所能做的最好的事情是以下几点,但这些都没有奏效:
test = load_workbook(r'\\data4\users2\wyoung3\My Documents\Test.xlsx')
twb = test['Sheet2']
twbs = twb._tables
twbs = twbs.append(['s']) #this was my attempt to try and append an item to the bottom of the list
test.save(r'\\data4\users2\wyoung3\My Documents\Test.xlsx')
这导致我无法打开一个文件,并显示错误消息:
AttributeError: 'list' object has no attribute 'tableColumns'
有人能建议我如何着手解决这个问题吗
你问的问题不是很清楚,所以我会提供一些选择。用于
openpyxl
的tutorial实际上是相当不错的,因此您应该尝试使用它首先,使用Tables:
或者,如果您已经知道单元格位置,您可以简单地
insert_rows()
相关问题 更多 >
编程相关推荐