没有 Document 的 python 子类,无法访问受保护的成员 GetService
Cannot access protected member GetService without a python subclass of Document
我不断收到此错误,"Cannot access protected member GetService without a python subclass of Document" 在这行代码中... "progressService = Document.GetService(ProgressService)"
下面的代码旨在提示另存为对话框并将文件保存到特定位置的文件夹中。
代码如下:
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)
设置库管理器并确保我们可以访问指定的文件夹路径
ProgressService 和 LibraryManager 的 GetService 在应用程序而不是文档上。这应该适合您,假设您的库是在文件系统而不是 Spotfire 数据库上设置的。
如果您将 Spotfire 库存储在 Spotfire 数据库中,您的文件夹名和文件名将分别看起来更像“/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)
我不断收到此错误,"Cannot access protected member GetService without a python subclass of Document" 在这行代码中... "progressService = Document.GetService(ProgressService)"
下面的代码旨在提示另存为对话框并将文件保存到特定位置的文件夹中。
代码如下:
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)
设置库管理器并确保我们可以访问指定的文件夹路径
ProgressService 和 LibraryManager 的 GetService 在应用程序而不是文档上。这应该适合您,假设您的库是在文件系统而不是 Spotfire 数据库上设置的。
如果您将 Spotfire 库存储在 Spotfire 数据库中,您的文件夹名和文件名将分别看起来更像“/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)