Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Xlwings-引用保存的范围并附加其他值_Python_Excel_Python 2.7_Xlwings - Fatal编程技术网

Python Xlwings-引用保存的范围并附加其他值

Python Xlwings-引用保存的范围并附加其他值,python,excel,python-2.7,xlwings,Python,Excel,Python 2.7,Xlwings,我是一个相当缺乏经验的程序员,一直在尝试在Xlwings中练习一些基础知识,Xlwings是一个使用Excel的Python库。我在2.7工作 我已经用GUI做了一个小程序,它允许你简单地在Excel的列中添加条目。在尝试我的程序时,我立即注意到它覆盖了列中以前保存的值。我完全无法找到一个可行的解决方案,如何从一个具有范围特征的列表开始,然后继续附加到列表中 from Tkinter import * from xlwings import Workbook, Range root = Tk(

我是一个相当缺乏经验的程序员,一直在尝试在Xlwings中练习一些基础知识,Xlwings是一个使用Excel的Python库。我在2.7工作

我已经用GUI做了一个小程序,它允许你简单地在Excel的列中添加条目。在尝试我的程序时,我立即注意到它覆盖了列中以前保存的值。我完全无法找到一个可行的解决方案,如何从一个具有范围特征的列表开始,然后继续附加到列表中

from Tkinter import *
from xlwings import Workbook, Range

root = Tk()
wb = Workbook()

e1 = Entry()
e1.grid(row=1, column=2)

participant_list = [] 
"""I realize starting with an empty list will clear the range every time I
run the script, but am not sure what the correct solution should be."""

def pressed_button():

    entry = e1.get()
    e1.delete(0, END) # clear the entry widget
    temp = []
    temp.append(entry)
    participant_list.append(temp)
    Range('A1').value = participant_list
    print participant_list # just to test

b1 = Button(text="Add Participant", command=pressed_button)
b1.grid(row=2, column=2)

mainloop()

如果您能帮助我找到解决方案,我将不胜感激!我尝试了一些不同的方法,但是我很不好意思将它们放在我的演示代码ha中。

根据您的需要,您可以先读入数据并将其分配给参与者列表,或者您可以找到该列中最后使用的单元格:例如,如果没有空行,例如

rng = Range('A1').vertical.last_cell
...
Range((rng.row + 1, rng.column)).value = participant_list

行。

谢谢!我一定没有充分阅读文档,因为我没有意识到有last.cell函数。