Replace Data Tables from a file

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


#get filename from file chooser
d1 = OpenFileDialog()
d1.InitialDirectory='C:\myfiles\salesdata'
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["T1"]
table1.ReplaceData(ds)
table2 = Document.Data.Tables["T2"]
table2.ReplaceData(ds)
Previous
Next Post »