user4519587
user4519587

Reputation: 1

Align to the right values in uitable after formatting with html code

I have an annoying problem with Matlab coding: I have created a uitable which store values and I have implemented a function for highlight the number in cells in particular conditions. This has been done giving an html command, the problem is that after the setting of new colour the number from a "double" becomes a "cell" and updating the data in the table it highlights correctly the value, but aligns all the numbers to the left; instead I would like to keep them constantly on the right. I tried everything without positive results; I think is enough to add the alignment command in the html syntax, but somebody can give me some suggestion?

This is the part of the code:

tab = findobj('Tag',tab_name);
valrow = cellstr(num2str(tab.Data(index,1))); %number in the cell has to be highligthed
color = [1 1 0.4]; %yellow
clr = dec2hex(round(color*255),2)'; clr = ['#';clr(:)]';
valrow = strcat(...
          ['<html><body bgcolor="' clr '"text="#010101; font-weight: width=100px">'],...
          valrow);     %html code for highlight the number
fulltab = cellstr(num2str(tab.Data(:,1)));    %transform all the data in the table from double to cell
fulltab(index,1) = valrow;    % switch the old value in the tab with the same value highligthed
set(tab,'Data',[fulltab]);

As I said previously, this code works but put all the data in the table from right usual alignment to the left.

Upvotes: 0

Views: 1219

Answers (1)

Blade20004
Blade20004

Reputation: 1

I had the same problem... then I realized the width was set at 100% not the actual cell width. Once I made the correction the text was aligned within the width setting.

CellVal = strcat('',MaxOver,'');

Upvotes: 0

Related Questions