我是IronPython的新手,並嘗試使用下面的代碼將我的交叉表從Spotfire導出到Excel。IronPython腳本幫助 - 在SPotfire中將交叉表導出到Excel
如何修改此腳本以包含定義vizTable?
import System
from System.IO import FileStream, FileMode
from Spotfire.Dxp.Application.Visuals import TablePlot
from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import SaveFileDialog
SaveFile = SaveFileDialog() #GETS THE FILE PATH FROM THE USER THROUGH A FILEDIALOG
SaveFile.Filter = "xls Format (*.xls)|*.xlsx|*.xls|*.xlsx"
SaveFile.ShowDialog()
saveFilename = SaveFile.FileName
print "saveFilename=", saveFilename
stream = FileStream(saveFilename, FileMode.Create) #Export Table data to the file
vizTable.As[exportWellHeader]().ExportData(DataWriterTypeIdentifiers.ExcelXlsxDataWriter, stream)
stream.Dispose()
我不斷收到下面的錯誤。我已經設置了一個腳本參數,但不知道將腳本合併到哪裏。
錯誤消息:
saveFilename= C:\Users\D565046\Desktop\test 3.xlsx
Traceback (most recent call last):
File "Spotfire.Dxp.Application.ScriptSupport", line unknown, in ExecuteForDebugging
File "<string>", line 14, in <module>
NameError: name 'vizTable' is not definedMicrosoft.Scripting.Runtime.UnboundNameException: name 'vizTable' is not defined
at IronPython.Runtime.PythonContext.MissingName(SymbolId name)
at Microsoft.Scripting.Runtime.LanguageContext.LookupName(CodeContext context, SymbolId name)
at $456##456(Closure , Scope , LanguageContext)
at Spotfire.Dxp.Application.ScriptSupport.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)
謝謝你的幫助,但我仍然得到下面的錯誤,當我替換它仍然給我下面的錯誤。有什麼建議麼? SaveFilename = C:\用戶\桌面\ rf.xlsx 回溯(最近通話最後一個): 文件 「Spotfire.Dxp.Application.ScriptSupport」,行未知,在ExecuteForDebugging 文件 「」,14號線在 NameError:name'vizTable'is not defined Microsoft.Scripting.Runtime.UnboundNameException:name'vizTable'is –
gingineer
嗨,你是否包含'vizTable'作爲腳本參數?該錯誤似乎說vizTable沒有定義。是否有可能用新的屏幕截圖更新你的文章? – HalcyonicDays