I have created a power automate flow to execute a sql query and create a sharepoint file in excel format everyday and load the retrieved select query to the excel file. Can anyone suggest what to provide in file content in the below screenshot and also how to load data into excel file in sharepoint?
CodePudding user response:
First of all, create a template Excel file in the SharePoint folder your flow will have access to (called Template.xlsx
below) ...
Now in your flow, copy that workbook to another workbook in another folder, I've done that to the Completed
folder. Technically, you could put it anywhere though ...
... now in the next step, rename your file by calling one of the API's on the SharePoint site in question ...
You need to make sure you enter the following headers and then body (be sure to parameterise your filename though) ...
Uri: _api/web/lists/getbytitle('Documents')/items(@{outputs('Copy_file')?['body/ItemId']})
Key | Value |
---|---|
X-HTTP-Method | MERGE |
If-Match | * |
Content-Type | application/json;odata=verbose |
Body
{
"__metadata": {
"type": "SP.Data.Shared_x0020_DocumentsItem"
},
"FileLeafRef": "New File Name.xlsx"
}
Now you have a true Excel workbook to work with.