I need an efficient way to color Excel cells based on value using Matlab activeX control

조회 수: 7 (최근 30일)
I currently process many hundreds of files each with about 24,000 data points. The processed results are then delivered to another team that does not use Matlab so instead an Excel spreadsheet is used. They have an automated tool that reads the sheet so I must output Excel. I have found that I can write the data to Excel very fast using these commands
[nr, nc] = size(array.(fn{i}).minrat');
c1 = get(AS.Cells, 'item', 2, hend + 1);
c2 = get(AS.Cells, 'item', 2 + nr - 1, hend + 1 + nc - 1);
range = get(AS, 'range', c1, c2);
vals = arrayfun(@(x) sprintf('%4.2f',x), array.(fn{i}).minrat, ...
'UniformOutput', 0);
set(range, 'Value', vals');
Applying the colors is much more painful.
color = array.(fn{i}).color';
for j = 1:nr
for k = 1:nc
c1 = get(AS.Cells, 'item', 1 + j, hend + k);
c1.Interior.ColorIndex = color(j, k);
end
end
I have used the profiler to show me where all my time is. For a run that took 272 seconds, 266 seconds where that inner loop. Previously the entire Matlab data was written out in the loop and finding the set range value was huge. Is there something I can do similar to that for colors?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by