I dont understand how to get the system.report.executeReport then save the CSV file sequence to work

I am trying to save a report viewer as a CSV file to do some secondary calculations on a table that is generated. I think I'm down the right path but cant seem to get the function to link.

I made a button then did an even "onClick" to a script.

I put in system.report.executeReport(path=self.getSibling("ReportViewer").props.source,fileType="csv")

I push the button and it doesnt toss an error.. from what i read, its because i need to actually save it somewhere.

I put in system.file.writeFile and i get an error that says...TypeError: writeFile(): takes no keyword arguments

Couple of questions...

  1. is the report viewer technically a dataset that I can download to a CSV file?
  2. if I need a path, what is a typical sequence. I don't do this often enough to remember.
  3. If there is something overly incorrect... what do I need to do to fix it? I'm drawing a blank.

I have looked at the examples in other forum section and I don't always speak the language so I'm not connecting the dots on how to fix it. :confused:

Please fix the missing tag and describe what you are trying to do.

This is in Perspective...

Are you saying that the report does not generate a dataset to download or convert?

This is the table...

If the report generates a table I can only download the report as a PDF via the little cloud button and not an xls/csv... then I'm sunk either way...

Yes. You can see in your screengrab that there is more in your report than just the table. You have a graphic, a title and the date range. None of these can be included in a CSV file. (You can read more on CSV format here.)

Instead you add a button to your Perspective view and write a script to generate the dataset and start the download.

1 Like

I added appropriate tags to the thread for you.

Lets get some terminology ironed out here.

  1. Report Viewer - component that can be configured to display a generated report.
  2. The table in the snipet you show, is not a the same as a "Table" component. It is a graphical representation that is generated by the report.

Because this is perspective it is important to understand that you can not just "write" a file anywhere. The client is running a browser, and browser security does not let applications write files where ever they wish. However, because, perspective executes on the Gateway, you can save a file on the gateway, and that location can be something that is available via the network. Otherwise, you can only allow the user to select where they would like for the file to be saved.

The system.report.executeReport() function returns a list of bytes which make up the report, which could then be used by system.perspective.download() to allow the user to save the data on their device

  1. What was the entire script that you used?
  2. Why do you need to save the report as a CSV to do secondary calculations?
  3. Where are you trying to save the file?
3 Likes
  1. What was the entire script that you used?
    At this point i have no idea what script to even start with... All i know is i have a table that is generated from a report that is pulling information in the format that i want it in from a SQL table. We just want to look at the generated values and not go back to the SQL table and start over if we can help it.
  2. Why do you need to save the report as a CSV to do secondary calculations?
    We want to quickly double check the calculations from a 1min report to a 3hr average report that we have running. If we take the 180 values and average them, it should equal(or be really close) to the 3hr average using the same data... we don't believe it is doing that at the moment.
  3. Where are you trying to save the file?
    We want to save it someplace simple... desktop, "downloads", "documents"... somewhere we can quickly get to and run the fast comparison calcs. It's more annoying than impossible type 180 values into a calculator and divide by 180..

It seems to me that you could do all that using SQL queries with the AVG() function. You would display the results on a Perspective view. No CSV. No downloads. No import to Excel. No formulas and formatting. No work!

Can you share the query that you're using in the report?

2 Likes