MATLAB Answers

How to use Excel application, how can i know all the functions and ways to use it?

6 views (last 30 days)
Bernardo Macara
Bernardo Macara on 3 Aug 2020
Commented: dpb on 4 Aug 2020
I have to do a lot of stuff in excel through matlab. I found out the easiest way to do all i wanna do is using excel aplication.
excel = actxserver('Excel.Application');
I wanted to know all the functions and possibilities that i can do like creating a graph or making multiple graphs write and delete some sheets and others.
Is there a place where i can get the information for this Excel.Application.
dpb on 4 Aug 2020
What will be done with the graphs in Excel that couldn't be done with the figures in Matlab?
If you would provide a sample data set and what is wanted to be done, someone could/would likely be able to show a pretty simple way to accomplish in Matlab.
I don't know anything about the above FEX submission; found it by searching for something that seemed to fit the scenario you were looking for so good luck if it works for you...
As you can tell, I'm not that enamored w/ Excel and particularly ActiveX -- I've just spent a month writing code to extract data from a whole bunch of Excel spreadsheets so could analyze/summarize it across some 100 workbooks. This was pretty painful for several reasons, one of which was that metadata was stored as comment in a cell and needed to be able to parse the cell formulas to track individual data entries for a cross comparison to separate databases.
IF one were really already proficient in VBA for Excel, this undoubtedly could have been done all in VBA; not being that person nor having anybody at hand who was, it necessitated using ActiveX to retrieve those pieces from the spreadsheets. Writing and debugging that code was simply terribly painful and time consuming owing to the reasons outlined above -- there is no clear documentation trail that covers actually writing ActiveX from MATLAB so one is left trying to decipher what it was that failed when something went wrong from less than helpful error messages (if any errorm message at all). And, every time that happens, odds are that the Excel process has been corrupted and orphaned in memory that requires killing in TaskManager before being able to try again.
If you've looked at the link, you'll see the Object Model is gargantuan -- just figuring out what pieces are those you need is a struggle.
As noted, one can try the expedient of recording macros for bits and pieces of what one wants to do and then try to translate that into ActiveX code, but even that isn't foolproof. Jeremy says "is in VBA, but the same features should be available." but I've discovered even that isn't true -- there are quite a few higher-level abstraction from the low-level calls available in VBA that are not interfaces that aren't duplicated directly. Unfortunately, it's not always clear when one is looking at one of these.
Anyways, just some context/background on my view...then again, of course, I don't have your specific job nor assigned task, either, just trying to see if maybe there's an easier way to get the result that might not need Excel in case hadn't thought of it...just assumed that Excel would be needed.

Sign in to comment.

Answers (1)

Jeremy Hughes
Jeremy Hughes on 3 Aug 2020
Active X is a Microsoft feature, controling the application depends on the APIs the application exposes. For Excel, you should check:
This is in VBA, but the same features should be available.

Community Treasure Hunt

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

Start Hunting!