Hi All ,
In the following post , we will see how to export DataTable / Gallery data to Excel from the PowerApps.
For this I am calling a Power Automate from Power Apps by passing the Name of the File and file Content. On Click of the button Power Automate will be called and It will create the file in SharePoint document library with the mentioned file name which we passed as parameter while calling power automate and the file will be opened in another browser tab.
Code in PowerApps :
1. Initially , I set the variable as empty/
Set(ExportCSVVar,"");
2. Set the Name of the file and below complete code will be executed when collection count is greater than zero
If(
CountRows(collErrorRegistration) > 0,
Set(
gblExcelFileName,
Concatenate(
"Export-",
Text(Year(Now())),
Text(Month(Now())),
Text(Day(Now())),
"-",
Text(Hour(Now())),
Text(Minute(Now())),
Text(Second(Now()))
)
);
3. here , I am defining the Header name of the Excel file and matching column names from the collection. In the below example \I have defined 3 column names .
Char(10) - will move to net row
Set(
ExportCSVVar,
"Column, Error Message, Time" & Char(10) & Concat(
collErrorRegistration,
Column & "," & Message & Now() & Char(10)
)
);
4. Calling the Power Automate by passing the File Name and File Content as parameters
Set(
gblFlowStatus,
ExportToExcel_ImportErrors_Restore.Run(ExportCSVVar,
gblExcelFileName
)
)
);
5. If the Power Automate returns Success , launching the exported file in new tab
If(
gblFlowStatus.completed = "true",
Launch(gblFlowStatus.url),
scrError
);
Helpful thank you Mahesh
ReplyDelete