如何使用 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
最佳答案
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
(请注意,您仍会获得默认情况下随每个文档创建的 MaxMissingTimeParts
和 FiscalYearOffset
属性。)
关于ironpython - Spotfire IronPython 循环遍历属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32433502/