Problem with xlsread when opening Excel files at network folder. (R2015a, Windows 7 64bits). Opening & saving files with Excel solves problem. WTF?!?

3 visualizaciones (últimos 30 días)
Hello,
We are working with a standalone matlab app we have created using R2015a in Windows 7 Enterprise (64bits). Since last week we have a problem with the app, and the line that produces the error is:
[Datos_Med, Texto_Med, ~] = xlsread(file_med,'Hoja1');
where 'Hoja1' is the sheet name (it's ok) and file_med is a char array (1x122) with value:
'\\almcommit.set.umi.net\vai\vaitratado\LINEA AEREA\Datos de auscultaciones\Mediciones VAI\L6\Datos OHL L6 V1 20120625.xlsm'
This is the error we get:
Error using xlsread (line 128) XLSREAD unable to open file '\\almcommit.set.umi.net\vai\vaitratado\LINEA AEREA\Datos de auscultaciones\Mediciones VAI\L6\Datos OHL L6 V1 20120625.xlsm'. File '\\almcommit.set.umi.net\vai\vaitratado\LINEA AEREA\Datos de auscultaciones\Mediciones VAI\L6\Datos OHL L6 V1 20120625.xlsm' not found.
This Excel file (an example) contains some data we want to save into a matlab table in order to analyze it. Obviously all these files exist, now and a week before, and they can be opened by Excel app and founded into their location in Windows (a network folder). There is no error inside them, and they weren't modified recently. This line also produce the same error when we run it from Matlab environment, so we can assume it isn't a app error.
The most strange thing about this problem is that when we open any of this files with Excel app, and we save them without doing any change, then xlsread works perfectly with these re-saved files. ¿¿??
We have contact with IT department in order to get detail about files permissions, and they report that all these files have the same properties. A solution could be manually open and save all of them, or use an app to do it automatically, but we would like to know the reason this line is returning that error...
Any idea?
Thanks in advance.
  2 comentarios
Raul
Raul el 31 de Jul. de 2015
Editada: Raul el 31 de Jul. de 2015
Wow. Open and close files without saving (with Excel app) also works if I execute xlsread immediately (some seconds after that).
I have added this line of code before xlsread:
exist('\\almcommit.set.umi.net\vai\vaitratado\LINEA AEREA\Datos de auscultaciones\Mediciones VAI\L6\Datos OHL L6 V1 20120625.xlsm', 'file')
It returns 0 when xlsread fails, and 2 when it works.
Some time after opening a file (1 minute for example), xlsread fails again.
Raul
Raul el 31 de Jul. de 2015
If I copy any of this files to my local machine, xlsread works without problems.

Iniciar sesión para comentar.

Respuestas (2)

Sudhanshu Bhatt
Sudhanshu Bhatt el 4 de Ag. de 2015
Editada: Sudhanshu Bhatt el 4 de Ag. de 2015
Hi Raul,
Since " xlsread " is working intermittently , one possible reason could be connectivity issues while working with a network drive. To check that, you can try loading other files on the network using "xlsread" function and see if you get the same error while reading other excel files?
Also, to make sure the path to the file is correct, you can use " uigetfile " function in MATLAB, which will open a dialog box, where you can browse to the location where the Excel sheet is present and load it.
For Example:
Step 1: Find the file and get it's path:
>> [FileName,PathName,FilterIndex] = uigetfile();
>> fullAddress = strcat(PathName,FileName);
Step 2: Use the path obtained and pass it to xlsread function:
>> sheetname = 'NameAge';
>> test = xlsread(fullAddress,sheetname);
Note: "xlsread" while working with protected excel files may require 'basic' option. More information on "xlsread" can be found in the documentation link below:
Another way to open a file is to use " fopen " function in MATLAB, which will return a value greater than or equal to 3 if it can open the excel file. This way we can test if the problem is with "xlsread" or with accessing the file on network drive.
For Example:
>> fileId = fopen(fullAddress);
More information on "uigetfile" and "fopen" can be found in the documentation links below:
If this does not resolve the issue, then you can contact MathWorks Technical Support by creating a case using the link below:
I am attaching a code snippet to read an excel file using "uigetfile" and "xlsread".
Hope this helps.
Thanks
Sudhanshu Bhatt
  1 comentario
Raul
Raul el 5 de Ag. de 2015
Editada: Raul el 5 de Ag. de 2015
Thanks for your help Sudhanshu.
Regarding to other Excel files in that network folder, this happens with all of them.
I have tried suggested procedure:
>> [FileName,PathName,FilterIndex] = uigetfile();
>> fullAddress = strcat(PathName,FileName);
>> sheetname = 'NameAge';
>> test = xlsread(fullAddress,sheetname) ;
And it works with a file that direct xlsread command cant load. In this case fullAddress I'm getting is:
K:\vaitratado\LINEA AEREA\Datos de auscultaciones\Mediciones VAI\L2\Datos OHL L2 V2 20140605.xlsm
It seems to be a problem resolving network folder name (almcommit.set.umi.net) into system unit (K) or something similar. I have created a new variable fullAddress2 with:
\\almcommit.set.umi.net\vai\vaitratado\LINEA AEREA\Datos de auscultaciones\Mediciones VAI\L6\Datos OHL L6 V1 20120625.xlsm
And I executed:
>> fileId = fopen(fullAddress); (returns 3)
>> fileId = fopen(fullAddress2); (returns -1)
My IT department (that firstly said the problem was related for sure with my code...) is now analyzing network unit backup procedure.
Again, thanks a lot for your help.

Iniciar sesión para comentar.


Giulio Francesca
Giulio Francesca el 28 de Jul. de 2018
Hi Raul, I've got th same issue... how did you manage that?
Thank you

Community Treasure Hunt

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

Start Hunting!

Translated by