Spotfire Export Automatically

天大地大妈咪最大 提交于 2019-12-08 06:52:41

问题


I'm not at all sure that what I need is possible with the tools that I have, but I thought I'd ask.

I have the following Python script (technically IronPython, but I don't fully understand the difference), that I pulled from a blog and modified for my purposes:

import datetime
from System.IO import StreamWriter
from Spotfire.Dxp.Application.Visuals import TablePlot

tempFolder = "C:\\Spotfire Exports\\"
tempFilename = "Data.txt"

writer = StreamWriter(tempFolder + tempFilename)
vTable.As[TablePlot]().ExportText(writer)

print tempFolder + tempFilename

The script itself works perfectly fine, but the problem is that I need to be able to make this run automatically at a certain time of day, i.e., I need the *.txt file to be updated in the morning before I get to my desk. (The project pulls from a database that isn't accessible through MS Access.)

Although the script runs fine, I have to manually push the button to activate it. I can't seem to find any way to have the script run on file open (so that I can use Windows Task Scheduler) to make it run when the file is opened.

Does anybody know if there's a way to do this?

Bear in mind, I do not have Visual Studio available to me. I already tried Visual Studio Express, and it doesn't seem to be able to access the Spotfire SDK macros.


回答1:


You can utilize JavaScript to click a button on load and have that button be your python script. Like so:

window.onload = function callButtonClickEvent(){
          document.getElementById('YOUR_SPOTFIRE_CONTROL_ID').click();
}

By clicking "edit HTML" in the text box you're using you can see the ID spotfire has assigned your button. The above code will click that button once upon loading.

If you do not want your button to be shown to end users (if applicable) then you can put it inside a hidden div or span:

<span style='display:none'><SpotfireControl id="YOUR_SPOTFIRE_CONTROL_ID" /></span>

Then once this is setup it should run your script when opened as per your windows task scheduler as you desired.

Let me know if you have any questions regarding implementation.



来源:https://stackoverflow.com/questions/30040727/spotfire-export-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!