在spotfire中保存用户输入

问题描述 投票:0回答:2

能否在Spotfire中保存用户输入的数据?我的意思是,我可以要求用户提供对一个给定报告的评价吗?或者我可以在服务器中以任何方式保存一些其他信息,如网络浏览器,操作系统等?

spotfire
2个回答
0
投票

你可以使用python脚本来附加数据到Spotfire的数据表。

使用复制和粘贴在spotfire中创建一个表(没有值,只有标题),比如两列Rank和Comment。然后创建一个两个文档属性,每列一个。

添加一个按钮来运行append脚本,把你的两个文档属性和append到你的数据表。

这个python脚本看起来像:

from Spotfire.Dxp.Data import AddRowsSettings
from System.IO import  StreamWriter, MemoryStream, SeekOrigin
from Spotfire.Dxp.Data import DataType, DataTableSaveSettings
from Spotfire.Dxp.Data.Import import TextFileDataSource, TextDataReaderSettings

x = Document.Properties['Rank']
y =Document.Properties['Comment']


print(x,y)

#Create some data with columns that match an existing table to which new rows need to be added. 
textData = "Rank,Comment,\r\n"+x+","+y+"\r\n" 
print(textData)

#Using a Memory Stream as a placeholder to write the columns to which can then be used to make a data source
stream = MemoryStream()
writer = StreamWriter(stream)
writer.Write(textData)
writer.Flush()
stream.Seek(0, SeekOrigin.Begin)

#Settings to tell the system the data types being imported.Here it is defined as a comma separated list of column index and their data types
readerSettings = TextDataReaderSettings()
readerSettings.Separator = ","
readerSettings.AddColumnNameRow(0)
readerSettings.SetDataType(0, DataType.String)
readerSettings.SetDataType(1, DataType.String)

textDataSource = TextFileDataSource(stream,readerSettings)

#Use settings here to automatically have the system match column names between the data table and the memory data source created above.
settings = AddRowsSettings(Document.ActiveDataTableReference,textDataSource)

#Add the rows from the datasource.
Document.ActiveDataTableReference.AddRows(textDataSource,settings)
© www.soinside.com 2019 - 2024. All rights reserved.