Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.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 使用Datanitro的交互式工作表_Python_Excel_Datanitro - Fatal编程技术网

Python 使用Datanitro的交互式工作表

Python 使用Datanitro的交互式工作表,python,excel,datanitro,Python,Excel,Datanitro,我正在尝试创建一个交互式工作表,它可以根据单元格值加载一些数据。例如,如果单元格“A1”更改为“Esstructura”,则范围(C2:E4)将加载数据3列表。下面的代码是一个好方法还是有更好的方法 data1 = [[1, 2, 3], [4, 5, None], [6, 7, 8]] data2 = [[10, 20, 30], [40, 50, 60], [70, 80, 90]] data3 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] static = Ce

我正在尝试创建一个交互式工作表,它可以根据单元格值加载一些数据。例如,如果单元格“A1”更改为“Esstructura”,则范围(C2:E4)将加载数据3列表。下面的代码是一个好方法还是有更好的方法

data1 = [[1, 2, 3], [4, 5, None], [6, 7, 8]]
data2 = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]
data3 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

static = Cell("A1").value

while True:
    if static != Cell("A1").value:
        if Cell("A1").value == "mamposteria":
            CellRange("C2:E4").clear()
            Cell("C2").table = data1
        elif Cell("A1").value == "mortero":
           CellRange("C2:E4").clear()
           Cell("C2").table = data2
        elif Cell("A1").value == "estructura":
           CellRange("C2:E4").clear()
           Cell("C2").table = data3
        static = Cell("A1").value
那代码行得通。(while循环没有正确缩进,但我认为这是一个输入错误。)

下面是一个更有效的循环版本:

主要区别在于,每个循环读取一次A1的值-这比每次比较读取它要快

while True:
    new = Cell("A1").value
    if static != new:
        CellRange("C2:E4").clear()
        Cell("C2").table = {"mamposteria": data1,
                            "moretero": data2,
                            "estructura": data3}[new]
        static = new