简体   繁体   English

Spotfire自动导出

[英]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: 我有以下Python脚本(从技术上讲是IronPython,但我不完全了解其中的区别),我从博客中提取了该脚本并对其进行了修改:

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. 该脚本本身可以很好地工作,但是问题是我需要能够在一天的某个特定时间自动运行该脚本,即,我需要* .txt文件在早上到达办公桌之前进行更新。 (The project pulls from a database that isn't accessible through MS Access.) (该项目从无法通过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. 我似乎找不到任何使脚本在文件上运行的方式(以便可以使用Windows Task Scheduler)在打开文件时运行。

Does anybody know if there's a way to do this? 有人知道有没有办法做到这一点?

Bear in mind , I do not have Visual Studio available to me. 请记住 ,我没有可用的Visual Studio。 I already tried Visual Studio Express, and it doesn't seem to be able to access the Spotfire SDK macros. 我已经尝试过Visual Studio Express,但它似乎无法访问Spotfire SDK宏。

You can utilize JavaScript to click a button on load and have that button be your python script. 您可以利用JavaScript在加载时单击一个按钮,然后将该按钮用作python脚本。 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. 通过在您使用的文本框中单击“编辑HTML”,您可以看到Spotfire已为您分配了按钮的ID。 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: 如果您不希望将按钮显示给最终用户(如果适用),则可以将其放在隐藏的div或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. 然后,一旦设置好它,就可以按照Windows任务计划程序的要求运行脚本了。

Let me know if you have any questions regarding implementation. 如果您对实施有任何疑问,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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