I have a uitable that is displaying some data. When a value is greater than 1 I want the number to be in a red bold font.
This code gives me the correct output:
data(indx_red(:, n), n) = strcat(...
'<html><span style="color: #FF0000; font-weight: bold;">', ...
data(indx_red(:, n), n), ...
'</span></html>');
However when the number is greater than 5 I want the text to be bold red and the background colour of the cell to be blue. So I made the adjustment to my code below, but when I run this the background colour of the cells in the table does not change.
data(indx_red(:, n), n) = strcat(...
'<html><span style="color: #FF0000; font-weight: bold; background-color:powderblue;">', ...
data(indx_red(:, n), n), ...
'</span></html>');
I have also tried using a HTML table. The HTML parts I have checked with some HTML online editors to make sure the output is correct. Is there something in MATLAB that prevents you from colouring the background of a cell in a table?
How can I get a cell with a blue background, and a bold, red font?
data(indx_blue(:, n), n) = strcat(...
' <html><table border=0 width=50><tr><td style=''text-align: right; background-color:#99FF99''><b><font color=''#009933''>', ...
data(indx_blue(:, n), n), ...
'</font></b></td></tr></table></html>');
It seems named colours are not supported. However, if you give the background-color
as a hex value, it seems to work:
data = uitable;
data.Data{1,1} = '<html><div style="color: #FF0000; font-weight: bold; background-color:#b0e0e6;">11</div></html>';
Now this will only colour the background of the small area of the type. Giving size instructions could help styling the whole cell area:
data.Data{2,2} = '<html><div style="width:90px;height:12px;color: #FF0000; font-weight: bold; background-color:#b0e0e6;">11</div></html>'