I need an efficient way to color Excel cells based on value using Matlab activeX control
2 次查看(过去 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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!