<?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[Exporting Excel reports to csv]]></title><description><![CDATA[<p dir="auto">Heya,</p>
<p dir="auto">Can Excel reports be exported as csv instead of xlsx? It doesn't appear so but wanted to be sure that I haven't missed something.</p>
<p dir="auto">If not, is there any other facility to generate "reports" of data points to csv? I have a client requirement to create a report for a sensor node every hour and email it to them. Each report would contain 6 records, as data is logged every 10 mins. Ideally the report should contain the records for multiple sensor nodes.</p>
<p dir="auto">The other option is to generate the xlsx reports and have an automated process which picks up these reports from the server directory and converts them to csv. It would be ideal to avoid this option as it just adds a layer of complexity and maintenance.</p>
<p dir="auto">Thanks<br />
Ian</p>
]]></description><link>https://forum.mango-os.com/topic/4034/exporting-excel-reports-to-csv</link><generator>RSS for Node</generator><lastBuildDate>Thu, 14 May 2026 13:03:28 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/4034.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 29 Jan 2019 22:02:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Exporting Excel reports to csv on Wed, 06 Feb 2019 22:49:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/iperry" aria-label="Profile: iperry">@<bdi>iperry</bdi></a> said in <a href="/post/21290">Exporting Excel reports to csv</a>:</p>
<blockquote>
<p dir="auto">The part I was missing was using the subclass FileAttachment. doh</p>
</blockquote>
<p dir="auto">Yep, having the EmailAttachment class as an abstract class means it cannot be instantiated. Gotta use the public child classes.</p>
]]></description><link>https://forum.mango-os.com/post/21291</link><guid isPermaLink="true">https://forum.mango-os.com/post/21291</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Wed, 06 Feb 2019 22:49:19 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Wed, 06 Feb 2019 22:41:15 GMT]]></title><description><![CDATA[<p dir="auto">Awesome! Thanks Matt :)</p>
<p dir="auto">The part I was missing was using the subclass FileAttachment. doh</p>
<p dir="auto">All the parts work now. Once I get the code cleaned up, I will post it here.</p>
<p dir="auto">Need to make sure I bookmark the javadocs. I think I recall seeing them before but forgot all about them. heh</p>
<p dir="auto">Ian</p>
]]></description><link>https://forum.mango-os.com/post/21290</link><guid isPermaLink="true">https://forum.mango-os.com/post/21290</guid><dc:creator><![CDATA[iperry]]></dc:creator><pubDate>Wed, 06 Feb 2019 22:41:15 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Wed, 06 Feb 2019 20:50:44 GMT]]></title><description><![CDATA[<p dir="auto">Nailed It!<br />
I looked through the source code on git public. Here is your solution:</p>
<ol>
<li>get the full path to your attachment.</li>
</ol>
<pre><code>var toAttach = "/opt/mango/overrides/web/modules/mangoUI/web/ui/manifest.json";    
    var emailAttachment = new com.serotonin.web.mail.EmailAttachment.FileAttachment("manifest.json",toAttach);

</code></pre>
<p dir="auto">First parameter is the name of the file that will appear in the email. This means if your attachment hasa  really bizarre name or is timestamped to oblivion you can make it "Easier to read".</p>
<p dir="auto">NEXT:<br />
When you generate the email content object, simply call the in class method for attaching a file:</p>
<pre><code>emailContent.addAttachment(EmailAttachment ea )
</code></pre>
<pre><code>//simply generate and append
var emailContent = new com.serotonin.web.mail.EmailContent(null, writer.toString(), com.serotonin.m2m2.Common.UTF8);
emailContent.addAttachment(emailAttachment);
</code></pre>
<p dir="auto">THEN!</p>
<pre><code>com.serotonin.m2m2.rt.maint.work.EmailWorkItem.queueEmail(recipientsArray, "Email with attached file", emailContent, null); //FIRE!

</code></pre>
<p dir="auto">Et voila!</p>
<p dir="auto">Fox</p>
<p dir="auto">EDIT:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/phildunlap" aria-label="Profile: phildunlap">@<bdi>phildunlap</bdi></a> are there any javadocs?</p>
</blockquote>
<p dir="auto">Here is the link <a class="plugin-mentions-user plugin-mentions-a" href="/user/phildunlap" aria-label="Profile: phildunlap">@<bdi>phildunlap</bdi></a> provided we practically posted this within a few minutes of each other :D<br />
<a href="https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/web/mail" rel="nofollow ugc">https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/web/mail</a></p>
]]></description><link>https://forum.mango-os.com/post/21284</link><guid isPermaLink="true">https://forum.mango-os.com/post/21284</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Wed, 06 Feb 2019 20:50:44 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Wed, 06 Feb 2019 05:59:24 GMT]]></title><description><![CDATA[<p dir="auto">Nicely done Ian!<br />
To my recollection I cannot remember trying to attach anything. I know that it's a header based thing that will either go where that null is or we should be able combine the csv attachment amongst the email body. Sorry I'm not not near my pc atm to test. Think I might give it a go when I get home...</p>
<p dir="auto">This will be hugely beneficial for other mango users.<br />
Fox</p>
]]></description><link>https://forum.mango-os.com/post/21274</link><guid isPermaLink="true">https://forum.mango-os.com/post/21274</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Wed, 06 Feb 2019 05:59:24 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Tue, 05 Feb 2019 20:59:55 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/mattfox" aria-label="Profile: MattFox">@<bdi>MattFox</bdi></a></p>
<p dir="auto">So far so good. Using the examples you provided, I am able to query the data points I want for the last hour of samples and save the data to a csv file on the server.</p>
<p dir="auto">The email example works fine but I'm stuck trying to attach the csv file to the email. I haven't been able to find any javadocs or api docs for the Serotonin classes and my experiments haven't worked yet. Hopefully I haven't been blind. heh</p>
<p dir="auto">Do you have any examples of attaching a file?</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/phildunlap" aria-label="Profile: phildunlap">@<bdi>phildunlap</bdi></a> are there any javadocs?</p>
<p dir="auto">Thanks<br />
Ian</p>
]]></description><link>https://forum.mango-os.com/post/21272</link><guid isPermaLink="true">https://forum.mango-os.com/post/21272</guid><dc:creator><![CDATA[iperry]]></dc:creator><pubDate>Tue, 05 Feb 2019 20:59:55 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Wed, 30 Jan 2019 00:44:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/iperry" aria-label="Profile: iperry">@<bdi>iperry</bdi></a> Glad to be of assistance, you know I'll be here!</p>
<p dir="auto">Fox</p>
]]></description><link>https://forum.mango-os.com/post/21184</link><guid isPermaLink="true">https://forum.mango-os.com/post/21184</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Wed, 30 Jan 2019 00:44:08 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Wed, 30 Jan 2019 00:43:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/mattfox" aria-label="Profile: MattFox">@<bdi>MattFox</bdi></a></p>
<p dir="auto">Thanks for the starting points. As I pick through the requirements for the csv and email, it looks like the scripting data source is the more likely option. Will let you know how things go.</p>
<p dir="auto">Ian</p>
]]></description><link>https://forum.mango-os.com/post/21183</link><guid isPermaLink="true">https://forum.mango-os.com/post/21183</guid><dc:creator><![CDATA[iperry]]></dc:creator><pubDate>Wed, 30 Jan 2019 00:43:09 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Wed, 30 Jan 2019 00:27:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/iperry" aria-label="Profile: iperry">@<bdi>iperry</bdi></a> Fortunately Phil answered a question I had requesting that here in the forums:<br />
<a href="https://forum.infiniteautomation.com/topic/3741/get-roll-up-in-scripted-data-source/3" rel="nofollow ugc">https://forum.infiniteautomation.com/topic/3741/get-roll-up-in-scripted-data-source/3</a><br />
Here is what I based my email code off of:<br />
<a href="https://forum.infiniteautomation.com/topic/3147/email-last-day-s-events" rel="nofollow ugc">https://forum.infiniteautomation.com/topic/3147/email-last-day-s-events</a></p>
<p dir="auto">and for the RQL query:  (I grossly simplified mine)</p>
<pre><code>var allPoints = DataPointQuery.query("and(like(deviceName,My Device*),eq(name,probe1))&amp;sort(deviceName,name)&amp;limit(10000)");

</code></pre>
<p dir="auto">Then simply iterate through all of the points:</p>
<pre><code>for (var k = 0; k &lt; allPoints.length; k+=1) {
    //do magic here
    
}```</code></pre>
]]></description><link>https://forum.mango-os.com/post/21178</link><guid isPermaLink="true">https://forum.mango-os.com/post/21178</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Wed, 30 Jan 2019 00:27:20 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Tue, 29 Jan 2019 22:40:29 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/mattfox" aria-label="Profile: MattFox">@<bdi>MattFox</bdi></a></p>
<p dir="auto">The existing Excel scheduled report function would work fine if it was able to be generated as a csv instead of a xlsx. The csv report would be emailed as an attachment to the client.</p>
<p dir="auto">I guess the next question would be: what is the best way to generate a csv report containing multiple data points for a specific time period?</p>
<p dir="auto">Seeing the script you used would be interesting. At least gives me some insight as to how to create my own queries.</p>
<p dir="auto">Thanks<br />
Ian</p>
]]></description><link>https://forum.mango-os.com/post/21177</link><guid isPermaLink="true">https://forum.mango-os.com/post/21177</guid><dc:creator><![CDATA[iperry]]></dc:creator><pubDate>Tue, 29 Jan 2019 22:40:29 GMT</pubDate></item><item><title><![CDATA[Reply to Exporting Excel reports to csv on Tue, 29 Jan 2019 22:30:51 GMT]]></title><description><![CDATA[<p dir="auto">Does the CSV need to be added as an attachment?<br />
If not, why not just create a scheduled alarm and attach an email handler to it; populate the contents with your CSV data, and fire it?<br />
If you need to make it CSV attachment though. There is no reason why you cannot make the necessary headers and put your CSV in amongst it.<br />
EDIT: Sorry Ian, it appears I did it all with a scripting datasource not an event based system. If that's still of any use to you I don't mind sharing.</p>
<p dir="auto">Fox</p>
]]></description><link>https://forum.mango-os.com/post/21174</link><guid isPermaLink="true">https://forum.mango-os.com/post/21174</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Tue, 29 Jan 2019 22:30:51 GMT</pubDate></item></channel></rss>