什么是最快的方式创建,填充和着色行的MS Word表格通过ActiveX - > VBA(在我的具体情况下,我通过MATLAB做)?(MATLAB)ActiveX - > VBA - >填写/逐行着色MS Word表格最快的方法?
现在,我使用它以下列方式
hdlActiveX = actxserver('Word.Application');
...
hdlActiveX.ActiveDocument.Tables.Add(hdlActiveX.Selection.Range, nbRows, nbCols, 1, 1).Rows.Alignment = 1;
...
% create dataCell{nbRows, nbCols} containing the table values row- and columnwise
...
nrTable = ... % an integer selecting a table in the MS Word document
...
for r = 1:nbRows
for c = 1:nbCols
% Write data into current cell
hdlActiveX.ActiveDocument.Tables.Item(1).Cell(r,c).Range.Text = dataCell{r, c};
% setting a different background color rowwise, if a condtion is met
% this is even bigger performance reducer
if condition
for iCol = 1:nbCols
hdlActiveX.ActiveDocument.Tables.Item(nrTable).Cell(r,iCol).Select;
hdlActiveX.Selection.Shading.BackgroundPatternColor = color;
end
end
end
end
,但它需要年龄,真的,真的很长,以填补,特别是色彩的横行的MS Word(的ActiveX)表...那么如何提高填表的表现呢?
由于提前,