Driving Excel itself
Excel Online & Microsoft Graph
Workbooks in SharePoint and OneDrive, edited in place through the Graph API.
Start with the full guides
The long-form treatment of excel online & microsoft graph, with the reasoning the shorter pages assume.
Step-by-step how-tos
One task each, with code you can copy, run and adapt.
- How-toAdd a Chart to an Excel Online Workbook with Microsoft GraphCreate and maintain native charts in a workbook stored in OneDrive or SharePoint without downloading it: call the Graph charts/add endpoint with a type and source range, set the title and position, point an existing chart at new data with setData, fetch a PNG of the chart for an email, and run it all inside a workbook session — with the request code tested against a mocked Graph endpoint.
- How-toAdd, Rename and Delete Worksheets with Microsoft GraphManage the sheets of an Excel workbook in OneDrive or SharePoint from Python with Microsoft Graph: list worksheets, add a sheet, rename and reorder it, hide old ones and delete those past their retention — all inside a workbook session — with sheet names validated before the request, and a monthly rotation job tested against a mocked API.
- How-toAppend Rows to an Excel Online Table with Microsoft GraphAdd new records to an Excel table in OneDrive or SharePoint without downloading the file: match columns to the table header, skip rows already present, send rows in batches, and retry safely.
- How-toAuthenticate to Microsoft Graph with MSAL for Excel AutomationThe Excel workbook API accepts only delegated tokens, while file downloads work app-only. Set up MSAL device-code sign-in with a persistent token cache for scheduled jobs, and client credentials where they are allowed.
- How-toCall Excel Worksheet Functions Through Microsoft GraphUse Excel's own calculation engine from Python without Excel installed — call worksheet functions such as PMT and VLOOKUP on a workbook in OneDrive or SharePoint through Microsoft Graph, pass values and ranges as arguments, read results and Excel errors, and reuse a session for many calls.
- How-toCopy a Template Workbook in SharePoint with Microsoft GraphCreate new Excel workbooks from a template that lives in SharePoint or OneDrive using Microsoft Graph from Python: find the template by path, start a server-side copy into a destination folder, poll the asynchronous monitor URL until the copy finishes, handle name clashes, then fill in the copy through the workbook API without downloading anything.
- How-toCreate a New Workbook in OneDrive with Microsoft GraphCreate an Excel workbook in OneDrive or SharePoint from Python with Microsoft Graph: build the xlsx in memory, upload it with a simple PUT, control what happens when a file with the same name exists, use an upload session with correctly sized chunks for larger files, turn a range into an Excel table through the workbook API, and verify the requests before pointing the code at a real tenant.
- How-toHandle Microsoft Graph Throttling in Excel AutomationKeep Excel Online automation running when Microsoft Graph pushes back — honour Retry-After on 429 and 503 responses, back off with jitter on 504s, never blindly retry non-idempotent writes, run one worker per workbook, and handle throttled requests inside JSON batches. Includes a retry client you can test without a network.
- How-toRead an Excel File from SharePoint or OneDrive into pandasDownload a workbook from a SharePoint library or a user's OneDrive with Microsoft Graph and read it straight into pandas from memory — resolving sites and drives, skipping unchanged files, and handling whole folders.
- How-toRead and Write Excel Online Ranges with Microsoft GraphEdit a workbook in OneDrive or SharePoint in place: read a range or the used range into pandas, write a DataFrame back with the right address, send dates and number formats correctly, and avoid the null-means-skip trap.
- How-toRecalculate Excel Online Workbooks with Graph SessionsUse workbook sessions to make multi-call Graph jobs fast and consistent, force a recalculation before reading results, run what-if scenarios that are never saved, and handle slow session creation.
- How-toRun a Report When an Excel File Changes in OneDriveTrigger a report as soon as someone saves a workbook in OneDrive or SharePoint, instead of on a fixed schedule: poll the file's cTag cheaply, use the Graph delta query to find every changed workbook in a folder, or receive webhook notifications and answer Microsoft's validation handshake — with debouncing so a burst of autosaves runs the report once, and the code tested against mocks.
- How-toShare an Excel File in OneDrive with a Link Using GraphShare an Excel workbook stored in OneDrive or SharePoint from Python with Microsoft Graph: create view or edit links scoped to your organisation or to named people, set an expiry date, invite specific recipients with or without an email, list who has access, and remove links that are no longer needed.
- How-toSort and Filter an Excel Online Table with Microsoft GraphSort and filter an Excel table in OneDrive or SharePoint from Python with Microsoft Graph: apply multi-column sorts, filter a column by values, custom criteria or top items, read back only the visible rows, clear filters again, and decide when it is better to read the rows and filter in pandas instead of changing the shared workbook.
- How-toSend an Excel Report with the Microsoft Graph APIBasic SMTP auth is off in most tenants. Send the workbook through Graph instead: a client-credentials token, an inline attachment, and an upload session for larger files.
Compare the options
Which tool or approach to pick, and why.
Follow it through a track
Prefer an ordered route? These tracks cover excel online & microsoft graph along the way, in the order that builds on itself.
Related topics
Subjects that keep turning up on the same pages as this one, most overlap first.
Excel Online & Microsoft Graph is part of Driving Excel itself.