Ankita Bhattacharjee Posted February 2, 2017 Share Posted February 2, 2017 Hi All, This is regarding Tibco Spotfire. I was trying to export data table to an excel file using IronPython scripting. The script I am using is: from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers from System.IO import File writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter) filtering = Document.ActiveFilteringSelectionReference.GetSelection(table).AsIndexSet() stream = File.OpenWrite("SpotfireExport.xls") names = [] for col in table.Columns: names.append(col.Name) writer.Write(stream, table, filtering, names) stream.Close() Now the above script is working fine in Spotfire client, but when I am using the web player version the functionality is not working. I think I have to mention the download path and then download the excel file through the script. Can anyone have any idea on how to do that Thanks in advance, Ankita Link to comment Share on other sites More sharing options...
Andy-dont-use Pritchard Posted February 2, 2017 Share Posted February 2, 2017 Ankita, Please go to the new TIBCO Community site https://community.spotfire.com/ and ask your question in the "Answers" section. There won't be anyone monitoring this forum from the Spotfire community. Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted March 20, 2017 Share Posted March 20, 2017 Hello Ankita, Below is an Sample code that should work on both Client and Web Player. When you execute the script on WebPlayer the file is exported to the Spotfire Export folder under Web Player server . =============================== from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers from System.IO import File, Directory from System.Collections.Generic import List table = Document.ActiveDataTableReference writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter) allRows = Document.Data.AllRows.GetSelection(table).AsIndexSet() # directory if not Directory.Exists("C:\Spotfire_Export"): Directory.CreateDirectory("C:\Spotfire_Export") names = [] # columns stream = File.OpenWrite("C:\Spotfire_Export\Filename.xls") allColumnNames = List[str]() for column in table.Columns: allColumnNames.Add(column.Name) writer.Write(stream, table, allRows, allColumnNames) stream.Close() stream.Dispose() ============================= Link to comment Share on other sites More sharing options...
Peter Bij Posted January 30, 2020 Share Posted January 30, 2020 Hello Shandilya Peddi Thanks for the example. However, the export result ("C:\Spotfire_Export\Filename.xls") has zero records of the data file "table" Is this maybe due to the fact that my table is a on-demand table The on-demand table has been retreived and show clearly multiple records in the visualization, but my export (Excel) has only the headers and no details. Could you help me here Kind regards Peter Bij Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now