<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Can you relativise an Excel Report? Driven by WatchList Possibly?]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">If I have many like devices with consistent data point naming, is there a way to apply a single excel reporting template to them? Possibly the report could be driven by DataSource/DeviceName?</p>
<p dir="auto">I am just thinking of the functionality of the Dynamic Watch List and how this could be applied to reporting.</p>
<p dir="auto">Thank you.</p>
]]></description><link>https://forum.mango-os.com/topic/3044/can-you-relativise-an-excel-report-driven-by-watchlist-possibly</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 02:38:44 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/3044.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 30 Oct 2017 15:46:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can you relativise an Excel Report? Driven by WatchList Possibly? on Mon, 30 Oct 2017 21:35:25 GMT]]></title><description><![CDATA[<p dir="auto">Yeah there are definitely a lot of ways it could work. If they XIDs are programmatic or your fingers have too much sensation left, you can just have a big constant object you loop over....</p>
<pre><code>var configured = {"reportName": ["Xid-for-excelReports.timeSeries[0].points-position-0", "...-position-1"],
....
} //JSON.parse(someAlphanumericPointForStorage.value); //Or yeah, use the JSON store
</code></pre>
<pre><code>for(var report in configured) {
  var points = configured[report];
  foundTeplate.name = report;
  for(var k = 0; k &lt; points.length; k+=1)
    foundTemplate.timeSeries[0].points[k].pointXid = points[k];
  /* Do import, launch report, take a break, continue */
}
</code></pre>
]]></description><link>https://forum.mango-os.com/post/16017</link><guid isPermaLink="true">https://forum.mango-os.com/post/16017</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Mon, 30 Oct 2017 21:35:25 GMT</pubDate></item><item><title><![CDATA[Reply to Can you relativise an Excel Report? Driven by WatchList Possibly? on Mon, 30 Oct 2017 17:11:53 GMT]]></title><description><![CDATA[<p dir="auto">Thank you, Phil. I will try this out shortly.</p>
<p dir="auto">Your //notes make me think of possibly using json store to build the array. Maybe a simple page displaying watchlists or point hierarchies that the report could be applied to along with a checkbox. The array is then created by adding any checked device?</p>
]]></description><link>https://forum.mango-os.com/post/16015</link><guid isPermaLink="true">https://forum.mango-os.com/post/16015</guid><dc:creator><![CDATA[Wingnut2.0]]></dc:creator><pubDate>Mon, 30 Oct 2017 17:11:53 GMT</pubDate></item><item><title><![CDATA[Reply to Can you relativise an Excel Report? Driven by WatchList Possibly? on Mon, 30 Oct 2017 17:06:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi Wingnut,</p>
<p dir="auto">It's a great suggestion but not very easy at the moment. Possible, but not easy.</p>
<p dir="auto">Here's a scripting data source that's my off-the-cuff attempt to hack it....</p>
<pre><code>var dynamicTemplateXid="XLT_12345";
var foundTemplate = this.foundTemplate;
if(!foundTemplate) {
    var templates = JSON.parse(JsonEmport.getConfiguration("excel-report-templates"))["excel-report-templates"];
    for(var k = 0; k &lt; templates.length; k+=1)
        if(templates[k].xid === dynamicTemplateXid) {
            foundTemplate = this.foundTemplate = templates[k];
        }
}

//For simplicity, I am going to run the report on every watchlist
// somewhat carelessly. Presumably you would want to filter down to just certain
// watchlists. You could encode an array of XIDs here, or track an index in the
// list if you need to break up executing the reports to multiple executions of 
// the script in a data point on the script....

var watchLists = JSON.parse(JsonEmport.getConfiguration("watchLists")).watchLists; //You may also need to check "watchlists"
for(var k = 0; k &lt; watchLists.length; k+=1) {
    var watchList = watchLists[k];
    if(watchList.dataPoints.length &lt; 2)
        continue;
    //Note that this is presuming static watchlists, but we could use the hierarchy instead
    // or try to construct queries. You could do extra work to identify points based
    // on foundTemplate.timeSeries[0].points[k].namedRange
    foundTemplate.timeSeries[0].points[0].pointXid = watchList.dataPoints[0];
    foundTemplate.timeSeries[0].points[1].pointXid = watchList.dataPoints[1];
    foundTemplate.name = "Report - " + watchList.name;
    var importText = JSON.stringify({"excel-report-templates":[foundTemplate]});
    JsonEmport.doImport(importText);
    //print(importText); print("\n\n");
    var reportTemplateVO = com.infiniteautomation.mango.excelreports.dao.ExcelReportTemplateDao.instance.getByXid(dynamicTemplateXid);
    com.infiniteautomation.mango.excelreports.rt.ExcelReportWorkItem.queueReport(reportTemplateVO, null, null, "report-script");
    RuntimeManager.sleep(3000);
}
</code></pre>
<p dir="auto">Tested and working</p>
]]></description><link>https://forum.mango-os.com/post/16014</link><guid isPermaLink="true">https://forum.mango-os.com/post/16014</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Mon, 30 Oct 2017 17:06:56 GMT</pubDate></item></channel></rss>