I am new to IronPython and trying to use the below code to export my cross table from Spotfire to excel.
How do I modify this script to include defining the 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()
I keep getting the below error. I have set a script parameter but do not know where to incorporate into the script.
Error messages:
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)
