Will upgrading Matlab or Excel fix this problem?
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Sean de Wolski
2013-11-20
XLSREAD calls the Excel COM api to open the file. If the 2002 version of Excel does not support *.xlsx, which a quick search indicates it does not, then you'll need a newer version of Excel. Alternatively, you could export the *.xlsx file as a *.csv and then read it in with csvread.
5 个评论
Sean de Wolski
2013-11-21
That error message is likely due to you accidentally typing "clear" in the middle of "isappdata".
Run the following and then run your file:
dbstop if error
Then Run you file. It'll stop on this line and you can remove the "clear" and save/exit/rerun.
更多回答(2 个)
Image Analyst
2013-11-21
编辑:Image Analyst
2013-11-21
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);
Iain
2013-11-21
编辑:Iain
2013-11-21
'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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!