是否可以通过调用某些API来以编程方式保存在Spotfire的Web Player(即 Spotfire Consumer )中打开的分析文件,或者由UI(Web Player)处理的分析文件?我正在使用Spotfire 10.1版
...以代码形式(例如使用Web API)
答案 0 :(得分:1)
感谢您的澄清!
以下IronPython代码将保存分析。您会发现一个限制,但是,在保存到Web Player中时,必须将右上角的下拉菜单必须设置为“查看”(在10.0中)。重申一下:您不能使用此代码在Web Player中保存当前处于“编辑”模式的文档。
from Spotfire.Dxp.Application import DocumentSaveSettings
from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemType, LibraryItemMetadataSettings
from Spotfire.Dxp.Framework.ApplicationModel import ApplicationThread
def save_to_library(app, path, filename, meta, settings):
def f():
app.SaveAs(path, filename, meta, settings)
return f
# path info
lib_path = "/path/to/file"
filename = "My Analysis"
# reference the LibraryManager
lm = Application.GetService[LibraryManager]()
# determine if the path exists
success, lib_folder = lm.TryGetItem(lib_path, LibraryItemType.Folder)
if success:
# save the file
Application.GetService[ApplicationThread]().InvokeAsynchronously(save_to_library(Application, lib_folder, filename, LibraryItemMetadataSettings(), DocumentSaveSettings()))
else:
print "folder " + lib_path + " does not exist in the Library"