readtable has stopped working on xlsx files

12 ビュー (過去 30 日間)
Karen
Karen 2025 年 4 月 1 日
移動済み: Walter Roberson 2025 年 4 月 2 日
I am running 2024a Matlab on a Windows PC. I have code that loads an existing sheet of an xlsx file. It was working at the beginning of March. I switched my personal Matlab library from dropbox to github (only change I'm aware of; no change to Matlab directories) and now I get the following error message:
T = readtable(filename, 'Sheet', 'sheet name');
Error using readtable (line 517)
Conversion to cell from char is not possible.
This error also occurs if I try:
opts = detectImportOptions(filename, 'Sheet', 'sheet name');
Error using detectImportOptions (line 428)
Conversion to cell from char is not possible.
I've tried this on 2 Windows machines. One was recently updated to Windows 11, the other is still running Windows 10.
What could have happened?
btw, if I type which -all readtable, I get the following on both machines:
C:\Program Files\MATLAB\R2024a\toolbox\matlab\iofun\readtable.m
C:\Program Files\MATLAB\R2024a\toolbox\shared\io\general\+matlab\+io\@ImportOptions\ImportOptions.m % matlab.io.ImportOptions method

回答 (1 件)

Walter Roberson
Walter Roberson 2025 年 4 月 1 日
移動済み: Walter Roberson 2025 年 4 月 2 日
The most common cause of these sorts of problems, is if you have a third-party .m file that is interfering with a MATLAB function. For example if you had a height.m or width.m then those sorts of problems can occur.
Experiment with
restoredefaultpath; rehash toolboxcache
(If the functions still do not work, there is the possibility that the interfering function is in your current working directory.)
  1 件のコメント
Karen
Karen 2025 年 4 月 2 日
移動済み: Walter Roberson 2025 年 4 月 2 日
Thanks! Restoring the default path worked and, by successively adding directories, I narrowed it down to one but it's still not clear which mfile in that directory is causing the problem (they seem totally unrelated in both name and function). I did note that matlab.io.internal.legacyReadtable does work, even if when the problem directory is in my path. For future investigations.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by