Problem to import data from Excel to Matlab

Hello, I've a problem to import data from excel file to Matlab. I'm using xlsread function in the following way:
[num,text]=xlsread('myxlsfile.xls')
then I receive this warning message:
"Warning: XLS File contains unrecognized string header - skipping remaining text - (1027:0x20 57307)"
and the 'text' matrix result truncate. I've tried to copy and paste the data in an other xls file, but the problem persist. My xls file is approximately 20MB.
Is it too large? Could anyone help me?
Thank you
Maddalena

6 comentarios

Kaustubha Govind
Kaustubha Govind el 10 de Jun. de 2011
What versions of MATLAB and Excel are you using?
Walter Roberson
Walter Roberson el 10 de Jun. de 2011
Also, which operating system? Some xlsread() features are only supported on Windows systems that have Excel installed.
Maddalena Mandarà
Maddalena Mandarà el 11 de Jun. de 2011
I use Matlab R2011 and Microsoft Excel 2011 and my operation system is Windows 7. I hope that it isn't system problem. Which other way I can use to import data from excel to Matlab? Thank you
Walter Roberson
Walter Roberson el 11 de Jun. de 2011
Does the same thing happen if you tell it which cells to read?
Is it a text file or a binary file? If it is a binary file, could you export it as a text file?
Image Analyst
Image Analyst el 12 de Jun. de 2011
Well there's your problem - you installed Excel 2011 on your Windows 7 computer. I didn't even know you could do that since that's a Apple Macintosh product. The latest Excel for Windows is 2010, while for the Macintosh it's 2011. Try installing Office 2010 for Windows instead. ;-)
Can you open that file in any version of Excel on any platform? It seems if it's a corrupt workbook with a corrupt header that even Excel wouldn't open it.
Maddalena Mandarà
Maddalena Mandarà el 12 de Jun. de 2011
Sorry, I've type Excel 2011 instead of Excel 2010. Anyway I tried to open my file on Excel 2008 on Macintosh system on an other platform, and there wasn't problem.
Unfortunately, my xls file contains numeric and text data, then I can not save it as a binary file and import it as a text file.
I've just try to import a selected range of my xls file, then I've type the command: [num,text]=xlsread('myxlsfile.xls','a1:bv5000') but the warning on 'unrecognized string header' appears. I've use this range because Matlab detective the problem at the row 4813 of the "text" matrix. Then
I've try to type the command: [num,text]=xlsread('myxlsfile.xls','a1:bv50') where the range don't include the row 4813.
The warning message persist because Matbal tell me that "Range cannot be used in 'basic' mode. The entire sheet will be loaded. ' Thank you for your help! Maddalena

Iniciar sesión para comentar.

 Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 12 de Jun. de 2011
On Windows machine, MATLAB opens Excel as a COM server to read data from Excel files. On other platforms, xlsread operates in what is called a 'basic' mode, which doesn't support some file formats. From the warning message that you receive: "Range cannot be used in 'basic' mode. The entire sheet will be loaded.", it seems that MATLAB is somehow unable to start-up Excel as a COM server. So the best path of resolution to your issue is to first resolve any errors occurring while starting Excel as a COM server.
Try executing the following command to see if you receive an error:
e = actxserver('Excel.Application')

11 comentarios

Maddalena Mandarà
Maddalena Mandarà el 13 de Jun. de 2011
When I execute the command
e = actxserver('Excel.Application')
I receive this error message
"??? Error using ==> actxserver at 91
Server creation failed. Invalid ProgID 'Excel.Application'"
How can I procede to solve this problem?
Kaustubha Govind
Kaustubha Govind el 13 de Jun. de 2011
Could you verify if you have 32-bit Excel on 64-bit Windows (if yes, I think you should also have 32-bit MATLAB)? Also, perhaps your system administrator can help determine why the ProgID corresponding to Excel has not been registered on your machine correctly.
Here is a relevant thread from Microsoft Answers: http://answers.microsoft.com/en-us/office/forum/office_2010-customize/problem-with-com-objects-with-office-2010/b6003b67-2050-4683-a660-18f1156fe388
Maddalena Mandarà
Maddalena Mandarà el 13 de Jun. de 2011
I use 32-bit Excel on 64-bit Windows, but I have 64-bit Matlab. Is it a problem? How can I install 32-bit Matlab?
Kaustubha Govind
Kaustubha Govind el 14 de Jun. de 2011
Yes, this is very likely the problem. See this solution for help on installing 32-bit MATLAB on win64: http://www.mathworks.com/support/solutions/en/data/1-579TVF/index.html?solution=1-579TVF
Eric
Eric el 14 de Jun. de 2011
I use 32-bit Excel from 64-bit Matlab all of the time. Only 32-bit COM objects defined in DLLs are inaccessible, not those defined in 32-bit EXEs.
See
http://www.mathworks.com/support/solutions/en/data/1-35LZ4G/
and
http://msdn.microsoft.com/en-us/library/aa384231(VS.85).aspx
-Eric
Kaustubha Govind
Kaustubha Govind el 14 de Jun. de 2011
Ah! Thanks for the information Eric - I wasn't aware of that.
@Maddalena: Perhaps you should check your Excel installation to ensure that the Excel ProgID is registered.
Maddalena Mandarà
Maddalena Mandarà el 16 de Jun. de 2011
Thank you for your answers! I'll try to unistall and install Excel in order to verify the correct registration of ProgID. I'll get you know!
Maddalena Mandarà
Maddalena Mandarà el 30 de Jun. de 2011
I contacted my system administrator and he confirmed the corrected installation of Excel 2010, but the problem persist. Do you have other ideas to solve this problem? Thank you!
Kaustubha Govind
Kaustubha Govind el 30 de Jun. de 2011
Maddalena: If you're familiar with VBA, could you try starting the Excel COM server from outside MATLAB to see if you are able to do so? This well help you isolate the issue to either MATLAB or Excel.
Another thing that I would try is to run MATLAB as Administrator and then try actxserver, to see if UAC is causing any restrictions.
Besides this, you could try contacting MathWorks Technical Support to see if they have any other tricks.
Maddalena Mandarà
Maddalena Mandarà el 15 de Jul. de 2011
I solved the problem with the help of MathWorks Technical Support. I used an Excel's vitualized version and this was the gap. Now, I use an Excel's application version and xlsread work very well.
Thank you to all
Maddalena
Kokalz
Kokalz el 16 de Jul. de 2012
Could you give a full discription on the problem solving steps that your performed? Thank you!

Iniciar sesión para comentar.

Más respuestas (2)

Guido Travaglini
Guido Travaglini el 12 de Jun. de 2011

0 votos

Make sure the path shown in the "Current Folder" window is the same where your XLS file resides.

1 comentario

Maddalena Mandarà
Maddalena Mandarà el 12 de Jun. de 2011
Yes, the Current Folder windoew is the same where my xls file resides. Anyway I've type the path in the argument of xlsread function.
Thank you!
Maddalena

Iniciar sesión para comentar.

Kokalz
Kokalz el 16 de Jul. de 2012

0 votos

Could you give a full discription on the problem solving steps that your performed? Thank you!

2 comentarios

Maddalena Mandarà
Maddalena Mandarà el 16 de Jul. de 2012
Sure! I simply installed Excel using the CD, and not by downloading it from its website. If you need other informations, let me know.
Kokalz
Kokalz el 16 de Jul. de 2012
How did you find out you were using the virtualized version of Excel?

Iniciar sesión para comentar.

Categorías

Community Treasure Hunt

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

Start Hunting!

Translated by