MATLAB: Problem with xlsread: xlsread keeps hanging when executed

xlsread

Hi all,
I have a very weird problem with the xlsread function. I have made an application that is compiled in an executable. This executable reads in data from multiple excel files when it is run. Also, the executable run is started from an excel add-in. The executable is run already for quite some time without too much problems and is regularly recompiled. But since a few days, it appears that from time to time xlsread keeps "hanging" when reading in data. It looks as if the code execution is just halted. Furthermore, we found out that:
  • The problem is not reproducable: with every run, the problem is happening in another part of the code (but every time when reading in excel data).
  • There is no error message.
  • Some pc's experience the problem, others not.
  • It can't be a network issue, because reading is done directly from the hard drive of the pc (C drive).
I have no clue about what could be the problem, especially I never had any problem reading in data in the past with the same code. Has anyone an idea what the problem could be (f.e. is there an excel update done by microsoft in the past weeks that could affect the excel read in in matlab?)?
Thanks for sharing your ideas!

Best Answer

Hello Rien,
I'm not entirely sure what the problem is, but I have a few ideas of things that might be related.
Make sure that you have the appropriate read/write permissions on the Excel files (and the parent folder) you are trying to use. 'xlsread' will usually hang if it does not have the appropriate permissions to read or write a file.
Also make sure that the files you are trying to view are not being opened twice, there could be some issue with trying to view a file when its already opened.
Its possible that this could be a memory issue as well. You can try viewing the memory usage of your program while its running and before it hangs. Its possible that something has changed on your machine and it can no longer handle the memory requirements for your application. Perhaps the Excel files has grown too big and is taking up too much room in memory.
Additionally, I think this is very unlikely a problem caused by an Excel update. Though one possible solution might be to reinstall both Excel and Matlab and see if that changes anything.
Hopefully one of these ideas can point you in the right direction to resolving your issue.
Thanks,
Ryan Santos