vibin m Posted December 15, 2015 Share Posted December 15, 2015 Hi All, Attached the file. I wanted to add a button to this cross table and export the data to an excel file. Kindly help. Thank you, Vibin. Link to comment Share on other sites More sharing options...
Sean Riley Posted November 15, 2016 Share Posted November 15, 2016 You can create a Text Area, and insert an Action Control which executes an IronPython script. Here is a sample script to save a cross table to an Excel .xls file (with prompt): 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)This requires that you define "crossTable" as an input parameter which is defined as the cross table you want to export. Link to comment Share on other sites More sharing options...
Richard Lake 4 Posted May 5, 2017 Share Posted May 5, 2017 Thanks Sean. I tried u[[{"fid":"112966","view_mode":"default","fields":{"format":"default","field_file_image_alt_text[und][0][value]":"","field_file_image_title_text[und][0][value]":""},"type":"media","attributes":{"height":"1038","width":"1483","class":"media-element file-default"}}]]sing this script but was unable to see the data. Wondering what I am missing. Link to comment Share on other sites More sharing options...
Sean Riley Posted May 5, 2017 Share Posted May 5, 2017 Your input parameter is called Viz1, and not crossTable like required: This requires that you define "crossTable" as an input parameter which is defined as the cross table you want to export. And you modified the following line incorrectly: te = crossTable.As[Viz1]() If you did want to keep your input parameter named Viz1 then this would be how to modify the script: te = Viz1.As[VisualContent]() Link to comment Share on other sites More sharing options...
Richard Lake 4 Posted May 8, 2017 Share Posted May 8, 2017 Got it. Thanks Sean! Link to comment Share on other sites More sharing options...
Richard Lake 4 Posted May 9, 2017 Share Posted May 9, 2017 And if I have 50 different visualizations (crosstables) that I would like to export to a common directory with the click of one action button. Is that possible as well I looked at the automation services but it only offers crosstable exports as text files. Link to comment Share on other sites More sharing options...
Namrata Gade 3 Posted May 2, 2018 Share Posted May 2, 2018 Hi Sean, When trying to implement this solution in 7.10 environemnt at my end , it works in professional client but gives attached error on webplayer. Any clue why this could be Link to comment Share on other sites More sharing options...
Hung Huynh Posted August 1, 2019 Share Posted August 1, 2019 Hi Sean, I tried this : SaveFile.Filter = "Excel Workbook (*.xlsx)|*.xlsx"However, the xlsx file cannot be opened. Do you know why your code only works with .xls files 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