Html in TextArea

#This is a very powerful script as you can include html from a document property to update a text area:

from Spotfire.Dxp.Application.Visuals import HtmlTextArea
vis = ta.As[HtmlTextArea]()
vis.HtmlContent = Document.Properties["HtmlInput"]

More details here

3 comments:

Jeff Rix said...

You could also use a string replace command. Would be useful for an if statement based on a document property.

from Spotfire.Dxp.Application.Visuals import HtmlTextArea
vis = ta.As[HtmlTextArea]()
str = vis.HtmlContent
str = str.replace("Apple","Banana")
vis.HtmlContent = str

philipp said...

copy/pasting exactly the original script (only changing the name of my document property) i get the following error:

Traceback (most recent call last):
File "Spotfire.Dxp.Application.ScriptSupport", line unknown, in ExecuteForDebugging
File "", line 2, in
NameError: name 'ta' is not defined

how can this be fixed? thank you so much!

Jose Leviaguirre said...

Phillip, ta is a script parameter that points to a text area. The script above replaces the entire content of the text area. As jeff said, you can replace portion of it by using a replace function.