I am needing to save/export report information to CSV or Excel but I am not sure how to do it now that the datasets seem to be used in the background by the reporting module. I just need the report data for selected date range to save as a .csv or .xml upon the push of a button. I have did this before with the old reporting but not sure how to do it on the new reporting?
If you want to do it with a button, use scripting: system.report.executeAndDistribute. Your action will be ‘save’ and the format will be ‘csv’ or ‘xml’. If your report component in the window has overridden any parameters, pass those in as well. You can use this script anywhere – you don’t need a report component defined on the screen to make use of this.
I had been trying to use the system.report.executeAndDistribute last week, but will that save the report to the Gateway Machine or to the Client? I need the report to be saved to client computer and also just ran into an error that I believe is caused by our Java path on Gateway maybe that is causing an error when I press the button that I was not getting last week.
Traceback (most recent call last):
File “event:actionPerformed”, line 3, in
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Could not initialize class sun.dc.pr.Rasterizer
caused by GatewayException: Could not initialize class sun.dc.pr.Rasterizer caused by NoClassDefFoundError: Could not initialize class sun.dc.pr.Rasterizer
Ignition v7.8.0 (b2015101414)
Java: Oracle Corporation 1.8.0_71
Well I found out that somehow ignition was pointing at 32 bit Java installation and causing the errors. Pointed to 64 bit installation and script began to work. Only problem now is…still do not know how to save a copy of report data to a client computer as a csv or xml. The system.report.executeAndDistribute is only saving to gateway server…and support said they would have to get back to me when they figure out how this can be down now?
Correct, system.report.executeAndDistribute happens on the Gateway.
system.report.execute will give you back the bytes of the report in the format you request, and you can then do what you want, including save it to the local computer. Be sure to add the right file name extension when you save it if you want your user to be able to open with a double click.
Ok I got it to work finally…so now just gonna work on the formatting. Thanks for your help and for Alexs’ help as well.