In this article, we will see how we can export collection
object data to CSV format from Canvas app using Power Automate.
We are going to keep the example very simple. You can extend
for your requirements.
Power Automate Flow to Create CSV file
- First, we’ll create a Power Automate Instant flow.
- Give proper name to the flow. The trigger type
will be PowerApps.
- We are going to take the input from PowerApps
(Canvas App), Select an input type (String/Text).
- Next Step: Add Compose (This will
create an object from the above data) and as an input, take data from previous
step(trigger).
- Next Step: Add Create CSV Table action.
- In the From
textbox, take this Expression: json(outputs('Compose'))
- Next Step: Add Create file action.
As you can see, we are creating file in SharePoint site. You need to specify
Site URL and specify Document library.
- Here, File Content is the output of the
previous action (Create CSV Table).
Canvas App to trigger file creation
- Create a Canvas app and add the power automate
flow (ExportToExcel) that we just created.
- Put a button on the page. This is to trigger the
file creation.
- Click on the button and in the OnSelect
Property, put this formula. Here, ExportToExcel is the flow name and SampleColl
is the collection object of actual data that we want to publish as CSV file.
ExportToExcel.Run(
JSON(
SampleColl,
JSONFormat.IncludeBinaryData
& JSONFormat.IgnoreUnsupportedTypes
)
);
·
When you run the canvas app and click on the button,
the flow will run and you will be able to see the CSV file created in the
specified SharePoint library.