我是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