I would like to export multiple table visualizations to multiple excel sheets in a single excel file from spotfire, Is there any ironpython script for it ?

I found  IronPython Script online which will export data table to excel sheet with filter conditions applied on rows, but when i try to remove columns and export it, its not working.
 Can some one please help me with this, need a ironpython script to export visulaization filtered data to excel sheet.

Below is the script i have tried:

import System
import clr
import sys

from sys import exit
from System.Windows.Forms import FolderBrowserDialog, MessageBox, MessageBoxButtons, DialogResult
from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers
from System.IO import File, FileStream, FileMode

#This is a list of Data Tables and their Excel file names. You can see each referenced below as d[0] and d[1] respectively.
#tableList = ["Table1"]            

#imports the location of the file so that there is a default place to put the exports.
from Spotfire.Dxp.Application import DocumentMetadata
dmd = Application.DocumentMetadata #Get MetaData
path = str(dmd.LoadedFromFileName) #Get Path
savePath = '\\'.join(path.split('\\')[0:-1])

dialogResult = MessageBox.Show("The files will be save to "+savePath
                +". Do you want to change location?"
                , "Select the save location", MessageBoxButtons.YesNo)
if(dialogResult == DialogResult.Yes):
    # GETS THE FILE PATH FROM THE USER THROUGH A FILE DIALOG instead of using the file location
    SaveFile = FolderBrowserDialog()
    savePath = SaveFile.SelectedPath

#message making sure that the user wants to exporthe files.
dialogResult = MessageBox.Show("Export Files."
                                +"  Export Files","Are you sure?", MessageBoxButtons.YesNo)
if(dialogResult == DialogResult.Yes):
    for d in tableList: #cycles through the table list elements defined above
        writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter)
        table =  Document.Data.Tables["Table1"] #d[0] is the Data Table name in the Spotfire project (defined above)
        filtered = Document.ActiveFilteringSelectionReference.GetSelection(table).AsIndexSet() #OR pass the filter
        stream = File.OpenWrite(savePath+'\\'+ "Table1" +".csv") #d[1] is the Excel alias name. You could also use d.Name to export with the Data Table name
        names = []
        for col in table.Columns: 
        writer.Write(stream, table, filtered, names)

#if the user doesn't want to export then he just gets a message
    dialogResult = MessageBox.Show("Ok")

(2) Answers