Why does Excel Link 2.1 (R13SP1) put cell arrays of mixed classes into MATLAB?
8 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Edited: MathWorks Support Team
on 4 Nov 2021
I have data in an Excel spreadsheet such that some cells contain text and other cells contain numeric data. If I put this data into MATLAB, it should appear as a cell array whose cells all contain strings. Even the numeric data should be exported as strings. This is documented at the following URL:
However, in Excel Link 2.1(R13SP1), the exported cell array contains mixed data. That is, the numeric data and empty cells are exported as class double.
Also, if I try to import that cell array back into Excel using MLGetMatrix, I receive the following error:
ERROR: MATLAB variable is not of a supported type.
This used to work in Excel Link 2.0 (R13).
Accepted Answer
MathWorks Support Team
on 3 Nov 2021
Edited: MathWorks Support Team
on 4 Nov 2021
This bug has been fixed for Release 14 (R14). For previous releases, read below for any possible workarounds:
As of Excel Link 2.1 (R13SP1), MLPutMatrix exports cell array data to MATLAB as a mix of numeric and char data rather than as all char data. This way, you do not have to use STR2NUM to convert your numeric data.
However, there is a bug in Excel Link 2.1 (R13SP1) in the way that MLGetMatrix imports mixed data into Excel.
To work around this issue, you can force Excel to use Excel Link 2.0 (R13) if you have MATLAB 6.5 (R13) available. Then you will be reverting to the original behavior, which is to use all character data on export and import of cell arrays.
In order to set up Excel to do this, use the following instructions:
1. Exit all versions of MATLAB and Excel that may be running.
2. Start Excel, and disable all Excel Link Add-ons.
3. Exit Excel.
4. Restart Excel, and enable the Excel Link 2.0 Add-on. If it is not available, then you will need to use "Browse" to locate the file at $MATLAB\toolbox\exlink\excllink.xla, where $MATLAB denotes your root MATLAB directory.
When doing this, you may encounter the following error:
ERROR: License Manager Dialog:
Excel Link license checkout failed!
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!