Every 15 minutes
Combine Excel files from OneDrive into one workbook
Every 15 minutes, rows from new Excel files dropped in a OneDrive folder are added to a table in one master Excel workbook, with the source file name on each row.
- Runs
- Every 15 minutes
- Apps
- Microsoft Excel, OneDrive
- AI
- Not needed
- Access
- Files.ReadWrite
Send this to your assistant
Create a ClickRuntime automation: every 15 minutes, take any new .xlsx file in my OneDrive folder "Store reports", read the rows from its first sheet and add them to the Sales table in Master.xlsx with the file name in the last column, then move the file to "Store reports/Imported".
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
When several stores, teams or clients each send an Excel file, someone spends time every week opening each one and pasting its rows into a master spreadsheet. People searching for how to import data from OneDrive into Excel usually mean exactly this: getting many files into one table.
This automation watches a OneDrive folder. Every 15 minutes it opens any new .xlsx file through Microsoft Graph, reads the rows on its first sheet and adds them to a table in your master workbook, with the source file name on each row. The file is then moved to an Imported subfolder.
Retail and franchise operators combining store reports, finance teams collecting department budgets and agencies merging client exports use it so the master workbook is always up to date and pivot tables refresh on real data.
What you get out of it
No copy and paste
Rows go straight from each file into the master table.
Source on every row
The file name column shows where each row came from, so mistakes can be traced back.
Each file once
Imported files move to a subfolder, which also shows at a glance what has been processed.
Excel files, not just CSV
It reads real .xlsx workbooks through Graph, so senders do not need to export anything.
Tables keep formulas working
Rows land in an Excel table, so formulas, pivots and charts based on it pick up new data.
How it works
What happens, step by step
Every 15 minutes the automation looks for new .xlsx files in the OneDrive folder.
It opens each workbook's first sheet through Microsoft Graph and reads the used rows, skipping the header.
It adds the rows to a table in your master workbook, with the source file name in an extra column.
The imported file is moved to an Imported subfolder so it is not read twice.
Before it runs live
- Connect Microsoft Excel
- Connect OneDrive
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Act only on the items that match your own rules, and skip the rest
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Microsoft Excel and OneDrive steps into one automation
Under the hood
The code that runs this automation
from clickruntime import on_trigger, credentials, http
GRAPH = "https://graph.microsoft.com/v1.0"
FOLDER = "/me/drive/root:/Store reports"
ARCHIVE_PATH = "/drive/root:/Store reports/Imported"
MASTER = "/me/drive/root:/Master.xlsx:/workbook/tables/Sales"
COLS = 6 # columns in the Sales table, including the final "source file" column
@on_trigger
def run(event):
h = {"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}
files = [f for f in http.get(f"{GRAPH}{FOLDER}:/children", headers=h, params={"$top": 200}).json()["value"]
if f.get("file") and f["name"].lower().endswith(".xlsx") and not f["name"].startswith("~$")]
added = {}
for f in files:
base = f"{GRAPH}/me/drive/items/{f['id']}/workbook"
sheet = http.get(f"{base}/worksheets", headers=h).json()["value"][0]["name"]
used = http.get(f"{base}/worksheets('{sheet}')/usedRange(valuesOnly=true)", headers=h).json()["values"]
rows = [(r + [""] * COLS)[:COLS - 1] + [f["name"]] for r in used[1:] if any(str(v).strip() for v in r)]
for i in range(0, len(rows), 500):
http.post(f"{GRAPH}{MASTER}/rows/add", headers=h, json={"values": rows[i:i + 500]}).raise_for_status()
http.patch(f"{GRAPH}/me/drive/items/{f['id']}", headers=h,
json={"parentReference": {"path": ARCHIVE_PATH}}).raise_for_status()
added[f["name"]] = len(rows)
return {"files": len(added), "rows": sum(added.values()), "by_file": added}FAQ
Common questions
Do all the files need the same columns?
Why does the master workbook need a table?
Does it work with files on SharePoint?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Import new CSV files into an Excel table
When a CSV lands in your OneDrive folder, its rows are added to your Excel table automatically.
See how it worksSave email attachments to OneDrive and log them in Excel
Attachments from your inbox are saved to OneDrive and each one is listed in an Excel log you can filter and search.
See how it worksAdd form responses to an Excel workbook
Every form submission is added as a row in your Excel workbook on OneDrive, with an email so you see it straight away.
See how it worksKeep exploring
Set up “Combine Excel files from OneDrive into one workbook” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.