Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Manipulate Excel From Matlab

Asked by George on 7 Oct 2011

Hi

How can i merge two or more excel cells from matlab? I think is something with actxserver function.

Thanks George

0 Comments

George

Products

No products are associated with this question.

1 Answer

Answer by George on 7 Oct 2011
Accepted answer
% MATLAB Automation client example 
%
% Open Excel, add workbook, change active worksheet, 
% get/put array, save.
% First, open an Excel Server.
e = actxserver('Excel.Application');
% Insert a new workbook.
eWorkbook = e.Workbooks.Add;
e.Visible = 1;
% Make the first sheet active.
eSheets = e.ActiveWorkbook.Sheets;
eSheet1 = eSheets.get('Item', 1);
eSheet1.Activate;
% Merge Cells
eActivesheetRange = e.Activesheet.get('Range', 'A1:B1');
eActivesheetRange.MergeCells = 1;

1 Comment

AwedBy Matlab on 14 Nov 2012

Can these activex commands be used on an existing XLS file? And can I create a spreadsheet with merged cells and save it as an excel file from matlab, but without the edits being done in real-time in Excel, like in the above code? Thanks!

George

Contact us