简体   繁体   中英

Load select query into excel file using power automate

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?

在此处输入图像描述

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.

重命名文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM