How to set excel cell color to red from Matlab?
显示 更早的评论
According to excel color index, the color index for red is 3.
In VBA, I can easily set red color, but in matlab code, I tried different numbers for Interior.ColorIndex, never got red color.
Anyone can tell me why? Thanks a lot.
-Derek
采纳的回答
更多回答(3 个)
Walter Roberson
2016-10-24
编辑:Walter Roberson
2016-10-24
Following along with Jiro's solution:
The list of color index values and associated colors can be found at http://dmcritchie.mvps.org/excel/colors.htm . There are 56 predefined colors.
You can also set the RGB color more directly. If you have R, G, and B in the 0 to 255 range, then:
C = double(R) * 256^0 + double(G) * 256^1 + double(B) * 256^2;
WB.Worksheets.Item(1).Range('A1').Interior.Color = C;
This is backwards of the typical order, but I have confirmed it works.
KRUNAL
2014-7-30
Hi Jiro,tell me what if the range is unknown? or to put it in a better way, if one wants to color only those cells that have specific strings characters in them. I did try xlsfont, but it does not work if I want to do
xlsfont('file.xls','Sheet1','Find','something','colorindex',3);
In ActiveX server too it is asking for range. What do you suggest to do? Do you think it can be done in some another way?
Prabhakaran thirugnanam
2016-10-24
0 个投票
What should be colorindex for other colors?
类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!