【问题标题】:matlab align to center a text of excel cellmatlab对齐以使excel单元格的文本居中
【发布时间】:2012-04-14 13:05:57
【问题描述】:

我有一个问题:如何将 'values{num_rows+1}' 的值放在 Excel 单元格的中心? 我看到我必须使用函数: set(ActivesheetRange,'Horizo​​ntalAlignment',3);但我不知道怎么用。

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

谢谢大家:]

【问题讨论】:

    标签: excel matlab text-alignment


    【解决方案1】:

    您需要使用Excel VBA object model,而不是 MATLAB 文本属性。

    将单元格值对齐到中心:

    range1.HorizontalAlignment = -4108;
    

    在此语句中,-4108 是 Excel 对象模型中定义的 xlCenter 常量。不知道如何从 MATLAB 中通过其名称访问它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-10
      • 2020-11-22
      • 1970-01-01
      • 2015-02-20
      • 2022-08-14
      • 1970-01-01
      • 2012-11-07
      • 1970-01-01
      相关资源
      最近更新 更多