我正在尝试使用自定义函数xlsfont
,但是由于某种原因,它对我不起作用。在此示例代码中,我试图将Excel中包含字符串“ Good”的单元格着色为蓝色,将包含字符串“ Bad”的单元格着色为红色。
animal = 'BL10';
filename = [animal '.xlsx'];
clust = 5;
endblock = 6;
totclust = 1:clust;
totblock = 1:endblock;
clusters = cell(1,clust+2);
clusters{1} = 'Cluster';
clusters{2} = ' ';
ind = 1;
blocks = cell(1,endblock);
for i = 3:length(clusters)
clusters{i} = ind;
ind = ind+1;
end
ind = 1;
for j = 1:length(blocks)
blocks{j} = ind;
ind = ind+1;
end
block_names = cell(1,endblock);
for k = 1:length(block_names)
block_names{k} = 'Block';
end
sheet = 1;
mat = cell(clust,endblock);
mat{1,1} = 'Good';
mat{1,2} = 'Bad';
xlswrite(filename,clusters(:),sheet);
xlswrite(filename,block_names,sheet,'B1');
xlswrite(filename,blocks,sheet,'B2');
xlswrite(filename,mat,sheet,'B3');
xlsfont(filename,'Sheet1','Find','Good','colorindex',5);
xlsfont(filename,'Sheet1','Find','Bad','colorindex',3);