Gustavo Pescador 2 Posted January 18, 2017 Share Posted January 18, 2017 Dear all, Hope you can help me with this. I am trying to create a script with python where I can export modified tables (say in the data source I included some calculated colums) and/or cross tables. So far I am able to export the raw data (as I specify the input parameter as the data table) into an excel file, which I need to create beforehand otherwise the script does not work. When I change the input parameter to a visualization (cross table) I got errors of -- None Typeobject has no attribute exportdata -- among others as I change the code on the way to try new things. The initial code is below. I have seen in the web that a lot of users have had the same complications with this and with them different codes which I have tried and none of the work, at least for me. I hope you can help me with this! Thanks in advance!! Gustavo 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("") names = [] for col in table.Columns: names.append(col.Name) writer.Write(stream, table, filtering, names) stream.Close() Link to comment Share on other sites More sharing options...
Sean Riley Posted January 18, 2017 Share Posted January 18, 2017 This is an example to export a Cross Table visualization to an excel file: 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() SaveFile.Filter = "Excel Workbook (*.xls)|*.xls" SaveFile.ShowDialog() saveFilename = SaveFile.FileName from Spotfire.Dxp.Application.Visuals import VisualContent,TablePlotColumnSortMode from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers from System.IO import File, StreamWriter writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter) stream = StreamWriter(saveFilename) te = crossTable.As[VisualContent]() te.ExportText(stream) Link to comment Share on other sites More sharing options...
Gustavo Pescador 2 Posted January 19, 2017 Author Share Posted January 19, 2017 Thanks a lot Sean! It works ;) Have a nice day! Link to comment Share on other sites More sharing options...
Grazia Palmisano Posted September 29, 2017 Share Posted September 29, 2017 Hello! This script does not work on WebPlayer Thank's Grace Link to comment Share on other sites More sharing options...
Grazia Palmisano Posted October 5, 2020 Share Posted October 5, 2020 Works but on webplayer download the file on server Node Manager, not on local machine of user that open the analisys.... 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