Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: More details -- actxserver('excel.application')
Date: Thu, 2 Jul 2009 15:22:25 -0400
Organization: The MathWorks, Inc.
Lines: 59
Message-ID: <h2j1c2$sus$1@fred.mathworks.com>
References: <h2iud6$c94$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1246562498 29660 144.212.105.187 (2 Jul 2009 19:21:38 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 2 Jul 2009 19:21:38 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:552509



"Andy Eisenberg" <theorigamist@gmail.com> wrote in message 
news:h2iud6$c94$1@fred.mathworks.com...
> I'm trying to write a GUI in MATLAB that should have the ability to read 
> from and write to an Excel spreadsheet arbitrarily.  (By that I mean, 
> given a range in a spreadsheet, I should be able to load the data into 
> MATLAB from the spreadsheet.  Or, given a range and an array that fits the 
> range, I should be able to write that array to that range.)  The problem 
> I'm having is one of documentation.  The MATLAB online documentation goes 
> as far as establishing the connection between MATLAB and Excel, namely:
>
> e = actxserver ('Excel.Application')
> e.Visible = 1;
> eWorkbooks = e.Workbooks
> w = eWorkbooks.Add
> e.Quit;
> e.delete;
>
> Elsewhere I've found things like:
>
> exl = actxserver('excel.application');
> exlWkbk = exl.Workbooks;
> exlFile = exlWkbk.Open([docroot 
> '/techdoc/matlab_external/examples/input_resp_data.xls']);
> exlSheet1 = exlFile.Sheets.Item('Sheet1');
> robj = exlSheet1.Columns.End(4);
> numrows = robj.row;
> dat_range = ['A1:G' num2str(numrows)];
> rngObj = exlSheet1.Range(dat_range);
> exlData = rngObj.Value;
> exl.registerevent({'WorkbookBeforeClose',@close_event1});
>
>
> But I only sort of understand this code because I can't find documentation 
> for the methods/properties anywhere.  The expression 
> exlSheet1.Columns.End(4) does the right thing, but I don't know why.
>
> Is there somewhere where I can find more complete documentation on the 
> Excel objects, including documentation on their methods, properties, and 
> common usage?  I am not against Reading The Fantastic Manuals, if only I 
> could find them.

Take a look at this section in the documentation:

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/brd4at8.html

Those methods and properties, like Workbooks, Open, Sheets, etc. are part of 
Excel's COM interface.  If you're looking for more information on those 
methods and properties (not how to use methods and properties in MATLAB) I 
think you're going to need to dig through the Microsoft Office Development 
documentation on Microsoft's website:

http://msdn.microsoft.com/en-us/library/bb726434.aspx

-- 
Steve Lord
slord@mathworks.com