Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow

Consider the scenario – you have a list of items in SharePoint and you’d like to export items created in the last 7 days to an Excel file in SharePoint – and then email the Excel file to someone.

Here are the steps:

  1. Create a blank flow and add a recurrence trigger. For testing I’m setting it to repeat every 7 minutes and this can be changed to suit your needs.
Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow 1

2. Clear existing rows from Excel table. The table is in the weeklyreport.xlsx file and the table name is table1 – it contains two columns, Title and CreatedDate. We’ll populate those columns from SharePoint. When selecting the actions use “Excel Business” since this file is stored in SharePoint.

Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow 2
Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow 3
The created date is unique so we’ll use that as an ID. Data from previous flow runs are now removed.

3. Set your date filters for selecting items from the SharePoint list. You can search for date time in Flow and select the “subtract from time” option. The report start date is 7 minutes earlier than the current time. You can change the time unit after testing.

Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow 4
The convert time zone above is for testing only – it shows the report start date in local time, in my case CST. The report end date is when the flow executes.

4. We’ll construct an Odata query to get items in the SharePoint list created in the last 7 minutes.

Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow 5
The filters above are “ReportStartDate” and “ReportEndDate”

5. Select an apply to each action.

Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow 6

6. Get the new file and send the email

Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow 7
You could add a dynamic name to the file if you wish.

The complete flow:

Export Items From a SharePoint List to Excel on a Recurring Basis Using Flow 8