Reputation: 7121
I have a question: how can I put the values of 'values{num_rows+1}' in the center of the excel cell? I saw that I have to use the function: set(ActivesheetRange,'HorizontalAlignment',3); but I don't know how to use it.
e = actxserver ('Excel.Application'); %# open Activex server
filename = fullfile(pwd,'example2.xlsx'); %# full path required
ewb = e.Workbooks.Open(filename); %# open the file
esh = ewb.ActiveSheet;
str = num2str(num_rows+1);
esh.Range(strcat('J',str)).Interior.Color = clr;
sheet1=e.Worksheets.get('Item', 'Sheet1');
range1=get(sheet1,'Range', strcat('A',str),strcat('I',str));
range1.Value= set(values{num_rows+1},'HorizontalAlignment',,'center');
thank everyone :]
Upvotes: 0
Views: 6727
Reputation: 19870
You need to use Excel VBA object model, not MATLAB text properties.
To align cell value to center:
range1.HorizontalAlignment = -4108;
In this statement -4108
is xlCenter
constant defined in the Excel object model. Don't know how to access it from MATLAB by its name.
Upvotes: 1