Will upgrading Matlab or Excel fix this problem?
Show older comments
I have some code which reads .xlsx (Microsoft Excel) files. It works on a PC with Matlab R2012a. I don't know what version of Excel that machine has.
I brought the code to my machine. I am using Matlab R2009a and MS Excel 2002 (which might even be corrupt). When I run the code on my machine, I was getting an xlsread error which said the .xlsx file was not MS Excel format (I no longer have the exact error message).
I thought the problem might be my outdated Excel application, so I installed the Excel viewer. But now when I run the code I get repeated errors "Undefined function or method 'isappdaclearta' for input arguments of type 'double'" from "gui_mainfcn" (part of Matlab). I tried uninstalling the viewer, and I still get that error.
I cannot find any function named 'isappdaclearta' and a web search of that name did not produce anything either.
Questions: 1) Does the version of Excel matter to the xlsread() or gui_mainfcn() routines? 2) Will upgrading my Matlab likely fix these errors? 3) What could be wrong? (And how do I fix it?)
Answer was a combination of the two answers below. I needed a new Excel version (or possibly the Excel viewer) and I corrupted the Matlab toolbox file gui_mainfcn.m. Not sure who to credit.
Accepted Answer
More Answers (2)
Image Analyst
on 21 Nov 2013
Edited: Image Analyst
on 21 Nov 2013
A viewer is a simple program that lets people just barely get by and view the file. I'm pretty sure that a viewer will not allow ActiveX control of it. MATLAB is still trying to write the xlsx file with your old version of Excel via ActiveX, not via the viewer since the viewer doesn't work with ActiveX. Thus, despite installing the viewer, it still won't work.
If you have the m-file source code you can instruct ActiveX to use the old format. See this snippet and incorporate it into your code accordingly:
% Prepare proper filename extension.
% Get the Excel version because if it's version 11 (Excel 2003) the file extension should be .xls,
% but if it's 12.0 (Excel 2007) then we'll need to use an extension of .xlsx to avoid nag messages.
excelVersion = str2double(Excel.Version);
if excelVersion < 12
excelExtension = '.xls';
else
excelExtension = '.xlsx';
end
% Determine the proper format to save the files in. It depends on the extension (Excel version).
switch excelExtension
case '.xls' %xlExcel8 or xlWorkbookNormal
xlFormat = -4143;
case '.xlsb' %xlExcel12
xlFormat = 50;
case '.xlsx' %xlOpenXMLWorkbook
xlFormat = 51;
case '.xlsm' %xlOpenXMLWorkbookMacroEnabled
xlFormat = 52;
otherwise
xlFormat = -4143;
end
% Add a new workbook.
ExcelWorkbook = Excel.workbooks.Add;
% Save this workbook we just created.
ExcelWorkbook.SaveAs(excelFullFileName, xlFormat);
'isappdaclearta'?
Ok. That looks like 'isappdata', but that you've tried debugging, typed clear, wondered where the mouse was, went to the command line, typed clear, and closed everything down, saving the now screwed up isappda - clear - ta
I suggest you try removing the "clear" from that line of code...
The latest version of excel has no problem using xlsread to read .xlsx files.
3 Comments
Jeff
on 21 Nov 2013
Image Analyst
on 21 Nov 2013
Looks like lain nailed it. Go ahead and mark his answer "Accepted".
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!