【发布时间】:2016-10-13 14:48:45
【问题描述】:
我是 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
回溯(最近一次通话最后一次):
文件“Spotfire.Dxp.Application.ScriptSupport”,行未知,在 ExecuteForDebugging
文件“”,第 14 行,在
中 NameError:名称“vizTable”未定义Microsoft.Scripting.Runtime.UnboundNameException:名称“vizTable”未定义
在 IronPython.Runtime.PythonContext.MissingName(SymbolId 名称)
在 Microsoft.Scripting.Runtime.LanguageContext.LookupName(CodeContext 上下文,SymbolId 名称)
在 $456##456(闭包,范围,语言上下文)
在 Spotfire.Dxp.Application.ScriptSupport.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)
【问题讨论】:
标签: export-to-excel ironpython spotfire