Jump to content

Data Export as Excel for Web Player

Karthikeyan TS

Recommended Posts

I need the users to export the data in table chart as excel on the click of a button from the text area. I need the detailed steps with a simple javascript/Iron Python to execyte the requirement. Require this help sincwe i am not exp in both iron python/js and with this i can build up my other requirements
Link to comment
Share on other sites

  • 3 years later...

The only method I've had work in both Desktop Client and Webplayer is using a JS to export HTML table to a CSV.

In the below example I'm taking a cross table and exporting to a text area. Then from text area I am using a JS to export to csv.



#Converts a tablePlot to an html table and adds export functionality. Works in webplayer and any browser that supports flash

# to POC, Add a data table and two text areas. Then define the two script parameters:

# visTA : target text area (a blank text area different from where this script will running as it will replace its contents)

# visDT : Data Table visualization


from Spotfire.Dxp.Application.Visuals import TablePlot, HtmlTextArea

ta = visTA.As[HtmlTextArea]()


from System.IO import Path, StreamWriter

from System.Text import StringBuilder


#Temp file for storing the cross table data

tempFolder = Path.GetTempPath()

tempFilename = Path.GetTempFileName()


#Export TablePlot data to the temp file

tp = visDT.As[TablePlot]()

writer = StreamWriter(tempFilename)



#Build the table

sb = StringBuilder()


#Open the temp file for reading

f = open(tempFilename)


#add some scripting magic from CDN

html = ' Page Title Export'


#build the html table

html += " n"

html += ""

html += " "

html += " ".join(f.readline().split("t")).strip()

html += " "

html += "n"

html += "n"


for line in f:

html += ""

html += "".join(line.split("t")).strip()

html += "n"


html += "n"

html += "n Double Click Here To View Details"



ta.HtmlContent = htmlHTML :



Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...