Report Viewer Data need to export as excel

I have use a report viewer to display the report

which contains any table for example like , simple table , normal table , Cross table.....
at the same time in single report it contain all table also...by binding with a multiple named Querys , basic SQL...

then I have used report viewer to display it on perspective in that as default it have Dowland option in the format of pdf.

but I required the data in the excel format.

You can use this function on a diferrent button to either email the report to you in csv or xlsx, or save it to a location on the gateway that is accessible to Ignition, and write a script to grab the file and download it.

https://docs.inductiveautomation.com/display/DOC81/system.report.executeAndDistribute

yeah

`# Executes and distributes the report to save a PDF`

`settings ` `=` `{` `"path"` `:` `"C:\\Ignition Reports"` `, ` `"fileName"` `:` `"Report.pdf"` `, ` `"format"` `:` `"pdf"` `}`

`system.report.executeAndDistribute(path` `=` `"My Report Path"` `, project` `=` `"My Project"` `, action` `=` `"save"` `, actionSettings` `=` `settings)`

let me change the format and will check.

	settings = {"path":"C:\\Ignition Reports", "fileName":"Report.xls", "format":"xls"}
	system.report.executeAndDistribute(path='ButylReports/SkidCleaningCheckSheet', project='DLB_NEW1', action="save", actionSettings=settings)
	

I tried no action have taken place

any suggestion please

Are you getting any errors in the gateway logs?

Have you checked the gateway's C:\Ignition Reports folder? Remember this script is being executed at the gateway, so it will save to the gateway, not your client.

my application is under this path

C:\Users\Administrator\.ignition

in that floder i can't find my xls file

can I change my path :thinking:

Ok, is the gateway installed on that computer?

If it is, then is there a C:\Ignition Reports folder?


yes .,create by manually

I have same problem as sara ,I need to print csv from a report ,I suceeded to run your script and receive the report ,but in the gateway C drive ,ignition reports folder .
the report was encrypted and unreadable in csv format as per attachment.
support pls
Reporttest.xls (220 KB)

Reporttest.xls opened fine in Excel.
There are graphics in it and the CSV format won't support that.

Thanks transistor.
I have two question :
1-why csv not support although i can send email with csv attachment from my report?

2-how to download file in my client machine ?

  1. CSV is a "flat file" format. Read the first table in this to get some idea of the loose specification.
  2. I don't know. You didn't supply any code or error messages.

Dear Transistor,
I am now able to download the csv file ,But it is downloaded on my gateway machine instead of my client machine .
how to modify my script pls?

	settings2 = {"path":"C:\\Ignition Reports", "fileName":"Reporttest.csv", "format":"csv"}
	system.report.executeAndDistribute(path='Power Management/CB', project='MegaMain', action="save", actionSettings=settings2)	

Regards,

Since this is a Perspective thread, then system.perspective.download | Ignition User Manual, I guess.

2 Likes

In case it isn't clear, you cannot distribute to a Perspective client's filesystem. You can only download through the browser, with only a suggested file name, and no control at all over the destination folder.

3 Likes

Thanks for support and patience,
It is working now.

I modified the script to be :

	bytesArray =system.report.executeReport(path='Power Management/CB2', project='MegaMain',parameters={'StartDate':self.parent.parent.getChild("ReportViewer").props.params.StartDate,'EndDate':self.parent.parent.getChild("ReportViewer").props.params.EndDate,'Circuit_Breaker_Name':self.parent.parent.getChild("ReportViewer").props.params.Circuit_Breaker_Name}, filetype="csv")	
	system.perspective.download(self.parent.parent.getChild("ReportViewer").props.params.Circuit_Breaker_Name+"\\"+str(self.parent.parent.getChild("ReportViewer").props.params.StartDate)+"\\TO\\"+str(self.parent.parent.getChild("ReportViewer").props.params.EndDate)+".csv", bytesArray)		```