我在 Tibco Spotfire 工作,想要一种方法来更新分析中的所有数据源。这可以使用此处描述的脚本完成:Spotfire - 如何添加重新加载按钮
我是这样实现的:
# * * *
#
# Update tables based on:
# https://stackoverflow.com/questions/49997755/spotfire-how-to-add-a-reload-button
#
# * * *
import ctypes
from System.Collections.Generic import List, Dictionary
from Spotfire.Dxp.Data import DataTable
from System.Collections import ArrayList
ctypes.windll.user32.MessageBoxW(0, "About to refresh all data from databases...", "Data Update", 1)
tables = ArrayList()
tables.Add(Document.Data.Tables["raw_table_col_detail"])
tables.Add(Document.Data.Tables["age_group"])
Document.Data.Tables.Refresh(tables)
ctypes.windll.user32.MessageBoxW(0, "Done with update.", "Data Update", 1)
我现在想实现这一点,以便它适用于任何分析。如何获取可用表的列表,然后遍历该列表(即如何动态执行上述操作而不必指定表名、“raw_table_col_detail”、“age_group”等)。
根据您使用的 Spotfire 版本,这里列出了几个选项https://community.tibco.com/wiki/how-refresh-or-reload-data-using-ironpython-script-tibco-点火
您可以遍历它们并一次刷新一个
import ctypes
ctypes.windll.user32.MessageBoxW(0, "About to refresh all data from databases...", "Data Update", 1)
for t in Document.Data.Tables:
t.Refresh()
ctypes.windll.user32.MessageBoxW(0, "Done with update.", "Data Update", 1)
或者您可以将它们推送到数组并一起刷新
import ctypes
from System.Collections import ArrayList
tables = ArrayList()
for t in Document.Data.Tables:
tables.Add(t)
ctypes.windll.user32.MessageBoxW(0, "About to refresh all data from databases...", "Data Update", 1)
Document.Data.Tables.Refresh(tables)
ctypes.windll.user32.MessageBoxW(0, "Done with update.", "Data Update", 1)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句