readtable can read Excel XLS but not XLSX on OneDrive?
Ältere Kommentare anzeigen
Hello!
Unable to open file 'C:\Users\juans\OneDrive\Juan\Matlab\Book5.xlsx' as a workbook. Check that the file exists, read access is available, and the file is a valid spreadsheet file.
A while ago, it was identified that there was an issue with OneDrive blocking Excel files, and you have to close the file on Excel in order for MATLAB to open it, which is very inconvenient for the workflow. Another workaround I found is to use XLS, which is also not always a good solution. I could not find whether this issue has been solved.
What is the current status of this issue? (I have 2023a)
Cheers!
Antworten (1)
Pavan Sahith
am 19 Jun. 2024
Bearbeitet: Pavan Sahith
am 19 Jun. 2024
0 Stimmen
Hello Juan,
I see that you encountering an issue when trying to read an Excel (.xlsx) file especially when the file is open in the background.
I assume you are using the readtable function in MATLAB for the above task.
I experienced the same issue in MATLAB R2024a. After researching similar MATLAB answers, I found that the problem is likely related to OneDrive locking the file for editing purposes.
OneDrive syncs files to the cloud when they are updated, which can cause the files to be locked temporarily, preventing write operations. Disabling OneDrive syncing can resolve this issue.
Here are a few workarounds that worked for me, which may also be useful for you:
- If the file is accessible on a HTTPS location, readtable can be used directly on the HTTPS path.
- The file can be moved or copied to a local directory, ensuring OneDrive does not lock it.
- if you are trying to write to the file, writing to a temporary location, then moving that file when you're done processing.
you can refer to the following MathWorks documentation which might help you
- websave- https://www.mathworks.com/help/matlab/ref/websave.html
- https://www.mathworks.com/help/matlab/ref/xlsread.html
also attaching the similar MATLAB answers for your reference
- https://www.mathworks.com/matlabcentral/answers/1587374
- https://www.mathworks.com/matlabcentral/answers/1909085
I hope this information helps you move forward.
1 Kommentar
Juan Saenz-Diez
am 21 Jun. 2024
Bearbeitet: Juan Saenz-Diez
am 21 Jun. 2024
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!