Replacing a data table with an excel worksheet using IronPython.

Hi,

I'm trying to write a script to replace data tables with worksheets from an excel file (sheets will have fixed names and dive locations).  The script I'm using as a template is:

# Replace tables from file
import clr
from System.Windows.Forms import OpenFileDialog
from Spotfire.Dxp.Data import *
clr.AddReference("System.Windows.Forms")

#get filename from file chooser
d1 = OpenFileDialog()
d1.InitialDirectory='C:\Users\data\test.xlsm'
d1.ShowDialog()

#setup data source from selected file
myDataManager = Document.Data
ds=myDataManager.CreateFileDataSource(d1.FileName)

#replace a couple of data tables
table1 = Document.Data.Tables["Table_1"]
table1.ReplaceData(ds)

This code is based off a similar previous question (https://community.tibco.com/questions/how-replace-data-table-using-ironp...).

When I run this code I firstly recieve the following error ImportError: No module named Forms. Secondly, Is it possible to adjust this code to replace a data table with a sheet from an excel file?

Any information would be greatly appriciated, thanks!

 

(Spotfire version 7.0.1.16)

 

(2) Answers

Login