2012-04-13 305 views
0

我有一個問題:如何將'values {num_rows + 1}'的值放在excel單元格的中心?我看到我不得不使用函數:set(ActivesheetRange,'Horizo​​ntalAlignment',3);但我不知道如何使用它。matlab對齊居中excel單元格的文本

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'); 

感謝大家:]

回答

1

您需要使用Excel VBA object model,沒有MATLAB文本屬性。

要單元格的值對準中心:

range1.HorizontalAlignment = -4108; 

在此語句-4108是在Excel對象模型定義xlCenter恆定。不知道如何從MATLAB的名稱訪問它。

+0

非常感謝! :] – 2012-04-14 16:14:38