【问题标题】:Spotfire IronPython Loop through propertiesSpotfire IronPython 循环遍历属性
【发布时间】:2015-09-07 07:44:22
【问题描述】:

如何使用 Ironpython 在 Spotfire 文件中返回完整的文档属性列表。

属性可以设置

Document.Properties["myProperty"] = "myValue"

我想做类似的事情

for myProperty in Document.Properties:
     print myProperty
     #Some checks like if myProperty.Name = 'name1' then ...

找到了这个,但还不能让它工作(它返回的不仅仅是属性:http://www.cambridgesoft.com/support/EnterpriseSupport/KnowledgeBase/FAQ/details/Default.aspx?TechNote=2344

from Spotfire.Dxp.Data import *

for DocProp in Document.Data.Properties.GetProperties(DataPropertyClass.Document):
    print DocProp.Name, DocProp.Value

【问题讨论】:

    标签: ironpython spotfire


    【解决方案1】:

    DocumentProperty 对象有一个名为isUserVisible 的属性可以帮助您。

    从技术上讲,列表中出现的所有内容都是文档属性(例如,它们是“文档的属性”),它们可以通过编辑»文档属性访问。要获得您期望的 DocumentProperties(如“在本文档中创建的变量”),您可以运行以下内容:

    from Spotfire.Dxp.Data import DataPropertyClass
    
    for d in Document.Data.Properties.GetProperties(DataPropertyClass.Document):
        if d.IsUserVisible: print d.Name, d.Value
    

    枚举只需要DataPropertyClass;不用导入也可以达到同样的效果:

    for d in Document.Data.Properties.GetProperties(0):
        if d.IsUserVisible: print d.Name, d.Value
    

    (请注意,您仍将获得默认情况下随每个文档创建的 MaxMissingTimePartsFiscalYearOffset 属性。)

    【讨论】:

    • niko,你知道你是否也可以用计算值来做到这一点? Document.Data.Values 之类的东西...?
    • @Freddy 所以您想要一个显示所有可用文档属性的计算值?您始终可以在 Value 部分中单独连接属性。还是您预计文档属性的数量会经常变化?
    • 我想在我的脚本中使用文本区域中的值(计算值)。想知道是否存在相同类型的循环来显示 Spotfire 文档中的所有计算值。但最后我只想使用一些特定的值。
    • @Freddy 我对 API 文档不太满意;我不知道这是否可能。你到底想得到什么?你想在你的 IP 神中使用表达式的结果吗?
    • 也在经历这些,没有结果。我可以复制计算,例如 1 是行数:Application.Document.Data.Tables["table name"] .RowCount。但是,其他计算值在某些列上具有函数数据限制,这导致了我的问题
    猜你喜欢
    • 2023-01-11
    • 1970-01-01
    • 2016-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 2014-01-26
    • 2018-04-13
    相关资源
    最近更新 更多