Fix Excel File Corruption After Uploading to SharePoint
Question details
The user needs to resolve an issue where Excel workbooks connected to a MySQL database become corrupted upon uploading to SharePoint and refreshing.

- Product
- Microsoft Excel, SharePoint Online
- Device & OS
- not provided
- Scenario
- Uploading and repeatedly refreshing Excel files (.xlsx and .xlsm) connected to an external MySQL database via SharePoint.
- Observed behavior
- The Excel workbook becomes corrupted, and the database connection is lost in both Excel for the Web and the Excel Desktop application.
Ensure you have a local backup of your original, uncorrupted Excel workbook saved on your hard drive before attempting any troubleshooting steps or refreshing external data connections.
Refresh Data Exclusively in the Excel Desktop Application
Use the desktop application instead of Excel for the Web to prevent web-based macro and data connection conflicts that lead to file corruption.
Excel for the Web has limitations when handling complex external database connections and VBA macros. Uploading these files to SharePoint and refreshing them via the browser often causes the backend structure of the file to become corrupted.
Navigate to your document library in SharePoint Online where the Excel workbook is stored.
Click the 'More options' (three dots) icon next to the file name, select 'Open', and choose 'Open in Desktop App'.
Once the file is safely opened in your local Excel application, navigate to the 'Data' tab and click 'Refresh All' to update the MySQL connection safely.

Request a Backend Investigation via Microsoft 365 Admin Center
If the file corrupts during the SharePoint upload process itself, server-side logs will be required to identify the root cause.
Try WPS Office for Reliable Spreadsheet Management
If you frequently experience file corruption and synchronization issues with Microsoft Office and SharePoint, consider switching to WPS Office. It provides a lightweight, highly compatible, and free alternative for managing complex spreadsheets and data without the heavy overhead.
- 1. Download WPS Office: Visit the official WPS website to download and install the free suite.
- 2. Open your spreadsheets: Launch WPS Spreadsheets and open your existing local Excel files directly.
- 3. Edit securely: Manage your data safely with full format compatibility and fast local performance.

Frequently Asked Questions
Why do XLSM files corrupt when opened in Excel for the Web?
Excel for the Web does not support running VBA macros. Opening and interacting with macro-enabled workbooks online can sometimes strip or corrupt the backend code. It is best practice to always open these files in the desktop application.
Can SharePoint handle external MySQL database connections in Excel?
While SharePoint can store the files, refreshing external data connections like MySQL often requires the desktop client or specific data gateways to work reliably. Attempting to refresh complex external queries in the web version can lead to data loss or file corruption.
How can I recover an Excel file that is already corrupted from SharePoint?
Try downloading the corrupted file from SharePoint directly to your local hard drive. Open your local Excel application, go to File > Open > Browse, select the downloaded file, click the arrow next to the 'Open' button, and choose 'Open and Repair'.




