123
Views
15
Comments
Solved
How to export the screen data to excel?
Application Type
Reactive

I have a screen with some labels and their inputs, and the data is coming into the inputs through a GET Api method. I need a button “Export to excel” on my screen, that can export all the data on screen in excel format.

2024-09-12 02-43-38
Deepsagar Dubey
Solution

Hi @Aman Kumar Bhardwaj 

If you are working in reactive the your button on click handler action is a client side action, and RecordListToExcel is not available at client side,

So you just need to create some logic here,

Create a server action and pass your list as input parameter which you want to export in list, and create a output variable of Binary data type and  assign RecordListToExcel  to this variable,

Use this server action in your button on click handler action and drag download widget over end then give file name and file content as output of your server action.

Below snapshots can help you.



I hope it'll help you,

Thanks
Deep

UserImage.jpg
Aman Kumar Bhardwaj

Hi
This is the server action:

I'm getting this error in RecordDataToExcel:


I am passing a input variable of the structure type that I got through the GET api response.
Can you please help?
Thankss.

2025-04-10 11-25-12
Diogo Reis

Hi Aman,

That error indicates that you are passing a single record of "GetUserTemplateResponse" instead of a record LIST of "GetUserTemplateResponse".

I am glad I could help.

2024-09-12 02-43-38
Deepsagar Dubey

Hi @Aman Kumar Bhardwaj 

RecordListToExcel takes list type variable and you are using single record.

UserImage.jpg
Aman Kumar Bhardwaj

Hi, @Deepsagar Dubey @Diogo Reis 

I need only one record of my API which is visible on the screen to be exported to excel.

So, How can i achieve this?

2025-04-10 11-25-12
Diogo Reis
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi,

Add a button to your screen and use the build in widget to export the recordlist from your table that shows the API data to excel.

https://success.outsystems.com/documentation/how_to_guides/data/how_to_export_entity_data_to_excel/

Regards,

Daniel

2024-09-12 02-43-38
Deepsagar Dubey
Solution

Hi @Aman Kumar Bhardwaj 

If you are working in reactive the your button on click handler action is a client side action, and RecordListToExcel is not available at client side,

So you just need to create some logic here,

Create a server action and pass your list as input parameter which you want to export in list, and create a output variable of Binary data type and  assign RecordListToExcel  to this variable,

Use this server action in your button on click handler action and drag download widget over end then give file name and file content as output of your server action.

Below snapshots can help you.



I hope it'll help you,

Thanks
Deep

UserImage.jpg
Aman Kumar Bhardwaj

Hi
This is the server action:

I'm getting this error in RecordDataToExcel:


I am passing a input variable of the structure type that I got through the GET api response.
Can you please help?
Thankss.

2025-04-10 11-25-12
Diogo Reis

Hi Aman,

That error indicates that you are passing a single record of "GetUserTemplateResponse" instead of a record LIST of "GetUserTemplateResponse".

I am glad I could help.

2024-09-12 02-43-38
Deepsagar Dubey

Hi @Aman Kumar Bhardwaj 

RecordListToExcel takes list type variable and you are using single record.

UserImage.jpg
Aman Kumar Bhardwaj

Hi, @Deepsagar Dubey @Diogo Reis 

I need only one record of my API which is visible on the screen to be exported to excel.

So, How can i achieve this?

2025-04-10 11-25-12
Diogo Reis
2023-04-16 15-25-31
Krishnanand Pathak

Hi @Aman Kumar Bhardwaj,

 
Follow the below steps to get the data from API and download data in excel format.
For demo I used hospital API.

Get data from API using data action:


Apply filter if you have any to filter API data. In below I did on the Hospital Name using dropdown value:


Pass the ListFilter.FilteredList to RecordListToExcel as shown below:


Assign the output of RecordListToExcel  to output variable(binary data ) of data action :



Download the excel using download node by passing the  output variable(binary data ) of data action as shown below:



You can check the demo to see how it will work through below link.

https://personal-qmzjggmd.outsystemscloud.com/FilterAPI/Test2?_ts=638191306886001839

Oml is also attached for reference.


Regards

Krishnanand Pathak





FilterAPI To Excel.oml
UserImage.jpg
Aman Kumar Bhardwaj

Actually, I'm not getting a List type response form API.
Can you provide any suggestions?

Thanks!

2024-09-12 02-43-38
Deepsagar Dubey

Hi @Aman Kumar Bhardwaj 

Create an Output variable of Record List type in your API method and as you saying your API will always return a single record then append this record in your List variable,

That's it, Then your issues will be solved,

Thanks
Deep

2023-04-16 15-25-31
Krishnanand Pathak

Hi @Aman Kumar Bhardwaj ,

Just create a local variable Record list of API response( like GetMedicalcollegesResponse Record List) datatype inside the data action.
Then use list append and append the local variable. then pass it to RecordListToExcel.

It should work.

Regards
Krishnanand Pathak



UserImage.jpg
Aman Kumar Bhardwaj

Hi,
It worked.
Thanks!

The data in excel is coming in alphabetical order,
Can I set the order that which column should come first?

2023-04-16 15-25-31
Krishnanand Pathak

You can use ListSort before RecordListToExcel.
To sort the excel data.

UserImage.jpg
Aman Kumar Bhardwaj

This is allowing to sort the list rows by a specific data.
But, I need to sort the Columns in the List as per any order.

2023-04-16 15-25-31
Krishnanand Pathak

You can define the columns by creating structure based on your requirement.
But this will not be a dynamic.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.