How to Unlock an Excel File in SharePoint Online Before Uploading
Question details
A console application fails to replace or upload an Excel file to SharePoint Online because the file is locked by a user who left the workbook open during a co-authoring session.

- Product
- Microsoft Excel / SharePoint Online
- Device & OS
- not provided
- Scenario
- Automating file uploads or replacing an existing Excel file in a SharePoint document library using a console application.
- Observed behavior
- The upload fails with a locked-file message because another user currently has the file open in an active SharePoint session.
Ensure you have SharePoint Administrator or Global Administrator privileges if you need to force-close active user sessions or configure tenant-wide idle sign-out policies.
Enable Idle Session Sign-out in SharePoint Admin Center
Automatically sign out users who leave their workbooks open after a period of inactivity to prevent file locks.
This is a proactive approach. By configuring idle session sign-out, SharePoint will automatically close inactive sessions, releasing the locks on co-authored Excel files so your automated applications can overwrite them without manual intervention.
Log in to the Microsoft 365 admin center with administrator credentials and navigate to the SharePoint admin center.
In the left-hand navigation menu, click on 'Policies' and then select 'Access control'.
Click on 'Idle session sign-out'. Turn on the feature by toggling the switch.
Specify the period of inactivity (e.g., 1 hour) before users are automatically signed out. Save your changes.

Revoke a User's SharePoint Session using PowerShell
Manually disconnect a specific user's active session to instantly unlock the Excel file for upload.
Discard or Override Document Check-out
If the file is locked because it was manually checked out rather than just left open in co-authoring, an admin can override it.
Try WPS Office for Seamless Spreadsheet Management
If you are looking for a reliable, lightweight, and cost-effective office suite, WPS Office provides excellent spreadsheet editing capabilities. It is fully compatible with Microsoft Excel formats and offers a familiar interface, making it easy to manage your data locally or collaborate via WPS Cloud without complex SharePoint locking issues.
- 1. Download and Install: Visit the official WPS Office website to download the free installation package.
- 2. Open WPS Spreadsheets: Launch the application and open your existing .xlsx files directly without any formatting loss.
- 3. Utilize Cloud Features: Sign in to your WPS account to save files to WPS Cloud for real-time collaboration and automatic backups.

Frequently Asked Questions
Why does a console application fail to upload an Excel file to SharePoint?
The upload fails if a user has the target Excel file open in a co-authoring session, causing SharePoint to lock the file to prevent conflicts. The application cannot overwrite it until the user's session is completely closed.
Does closing the browser tab immediately unlock the Excel file in SharePoint?
Not always. Sometimes the co-authoring session remains active in the background for a short period. Refreshing the library or waiting a few minutes usually clears the lock.
Can standard users unlock an Excel file left open by someone else?
No, standard users cannot force-close another user's active session. However, if the file is manually checked out rather than just open, a Site Owner or Administrator can override or discard the checkout.
How do I prevent users from accidentally locking files via co-authoring?
You can ask administrators to configure 'Idle session sign-out' in the SharePoint admin center, which automatically logs users out and releases their files if they are inactive for a set duration.




