简体   繁体   中英

Spotfire Export Automatically

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, ie, 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM