简体   繁体   English

Spotfire IronPython循环属性

[英]Spotfire IronPython Loop through properties

How can I return the full list of document properties in a Spotfire file, using Ironpython. 如何使用Ironpython返回Spotfire文件中的完整文档属性列表。

Properties can be set by 可以通过设置属性

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

I would like to do something like 我想做点什么

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

Found this, but can't get it to work yet (it returns more then just the properties: http://www.cambridgesoft.com/support/EnterpriseSupport/KnowledgeBase/FAQ/details/Default.aspx?TechNote=2344 发现了这一点,但无法让它工作(它返回的只是属性: 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

there is a property of the DocumentProperty object called isUserVisible that can help you here. 有一个名为isUserVisible的DocumentProperty对象的属性可以帮助你。

technically all the things that appear in your list are Document Properties (as in, they are "properties of the document"), and they are accessible via Edit»Document Properties . 从技术上讲,列表中出现的所有内容都是文档属性(例如,它们是“文档的属性”),可以通过编辑»文档属性访问它们。 to get the DocumentProperties you are expecting (as in, "variables created in this document") you can run something like the following: 要获取您期望的DocumentProperties(例如,“在本文档中创建的变量”),您可以运行如下所示的内容:

from Spotfire.Dxp.Data import DataPropertyClass

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

you only need DataPropertyClass for the enumeration; 你只需要DataPropertyClass来进行枚举; the same effect can be achieved with no imports: 没有进口可以达到同样的效果:

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

(note that you will stil get the MaxMissingTimeParts and FiscalYearOffset properties that are created with each document by default.) (请注意,默认情况下,您将获得使用每个文档创建的MaxMissingTimePartsFiscalYearOffset属性。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM