I am trying to export a Spotfire visualization to xlsx file. In order to export the data, I need to be able to write the visualization's data to a tempfile. The IronPython(2.7.7) script works when running as Spotfire Desktop App, since it is using the local machine's tempfile location. However, it does not work on the web since the script does not have permission to write to the server's tempfile location returned by Path.GetTempFileName()
.
How can I safely write to a tempfile via script for use in the web?
Script:
from System.IO import Path, File, StreamWriter
from Spotfire.Dxp.Application.Visuals import TablePlot
tf = Path.GetTempFileName()
writer = StreamWriter(tf)
# visTable is a script parameter pointing to a TablePlot
visTable.As[TablePlot]().ExportText(writer)
Error when run in web:
Could not perform action 'write_to_file'.
Could not execute script 'write_to_file': The directory name is invalid.
at Spotfire.Dxp.Application.Scripting.ScriptService.Execute(ScriptDefinition script, Dictionary`2 scope, InternalLibraryManager internalLibraryManager, NotificationService notificationService)
at Spotfire.Dxp.Application.Scripting.ScriptManager.<>c__DisplayClass8_0.<ExecuteScript>b__0()
at Spotfire.Dxp.Framework.Commands.CommandHistory.Transaction(Executor executor, Boolean visible, Boolean sticky, Guid stickyGuid, Boolean isHighlight)
at Spotfire.Dxp.Framework.Commands.CommandHistory.Transaction(String displayName, Executor executor)
at Spotfire.Dxp.Application.Scripting.ManagedScript.Execute(Dictionary`2 environment)
at Spotfire.Dxp.Application.HtmlTextAreaControls.ActionControl.ModifyCore(Object value)
at Spotfire.Dxp.Application.Visuals.HtmlTextArea.InteractWithControl(String id, Action`1 interaction)
IronPython Version: 2.7.7
Spotfire Version: 10.3.2.8
Edit: The builtin right click export functionality is not an option since the end goal is to inject my company's compliance information.