.net 如果没有文档的python子类,则无法访问受保护的成员GetService
我一直在这行代码中遇到这样的错误,“如果没有python文档的子类,就无法访问受保护的成员GetService…”。。。“progressService=Document.GetService(progressService)” 下面的代码旨在提示“另存为”对话框,并将文件保存到某个位置的文件夹中 代码如下:.net 如果没有文档的python子类,则无法访问受保护的成员GetService,.net,ironpython,spotfire,.net,Ironpython,Spotfire,我一直在这行代码中遇到这样的错误,“如果没有python文档的子类,就无法访问受保护的成员GetService…”。。。“progressService=Document.GetService(progressService)” 下面的代码旨在提示“另存为”对话框,并将文件保存到某个位置的文件夹中 代码如下: import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import Messa
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import
MessageBox,Form,MessageBoxButtons,DialogResult
from Spotfire.Dxp.Application import DocumentSaveSettings
from Spotfire.Dxp.Framework.Library import *
from Spotfire.Dxp.Framework.ApplicationModel import ProgressService
message="Would you like to save the file"
caption="Save to Library"
reply=MessageBox.Show(message,caption,MessageBoxButtons.YesNo)
def savetoLibrary():
folderName = r"C:\Users\Documents\NEW"
fileName = "TESTNEW.xlsx"
libraryManager = Document.GetService(LibraryManager)
success, libraryFolder = libraryManager.TryGetItem(folderName, LibraryItemType.Folder)
settings = DocumentSaveSettings()
Application.SaveAs(libraryFolder,fileName,LibraryItemMetadataSettings(), settings);
if reply==DialogResult.Yes:
progressService = Document.GetService(ProgressService)
progressService.ExecuteWithProgress("Saving to Library", "Saving analysis", savetoLibrary)
设置Library Manager并确保我们可以访问指定的文件夹路径GetService for ProgressService和Library Manager位于应用程序而不是文档上。假设您的库是在文件系统而不是Spotfire数据库上设置的,那么这应该对您有用 如果Spotfire库存储在Spotfire数据库中,则foldername和文件名将分别类似于“/Spotfire/Library/path”和“filename”
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import MessageBox,Form,MessageBoxButtons,DialogResult
from Spotfire.Dxp.Application import DocumentSaveSettings
from Spotfire.Dxp.Framework.Library import *
from Spotfire.Dxp.Framework.ApplicationModel import ProgressService
message="Would you like to save the file"
caption="Save to Library"
reply=MessageBox.Show(message,caption,MessageBoxButtons.YesNo)
def savetoLibrary():
folderName = r"C:\Users\Documents\NEW"
fileName = "TESTNEW.xlsx"
libraryManager = Application.GetService(LibraryManager)
success, libraryFolder = libraryManager.TryGetItem(spotfireLibraryFolder, LibraryItemType.Folder)
settings = DocumentSaveSettings()
Application.SaveAs(libraryFolder,fileName,LibraryItemMetadataSettings(), settings);
if reply==DialogResult.Yes:
progressService = Application.GetService(ProgressService)
progressService.ExecuteWithProgress("Saving to Library", "Saving analysis", savetoLibrary)