什麼是最快的方式創建,填充和着色行的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)表...那麼如何提高填表的表現呢?
由於提前,