questuion about cell2html FEX (showing numbers in green and else in black)
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
(This question relates on FEX section and sorry for asking here because of giving no answer in that section)
cell2html FEX,Tom Gaudette, is here: http://www.mathworks.com/matlabcentral/fileexchange/4874-cell2html-1-0-r1
Is it possible in this code for showing numbers in green color and string in black?
and while using of characters like '%','\' after converting not shows them. is there a way for supporting them also?
1 Comment
mohammad
on 23 Sep 2011
All dear please pay attention if my this question will be solved, percent of accept rate in my question increases to 90%, please help for increasing :))
Accepted Answer
Jan
on 23 Sep 2011
You can insert the code for a screen font manually:
C = {1, 4, 17}
D = cell(size(C))
for iD = 1:numel(D)
D{iD} = sprintf('<font color="#00C000">%g</font>', C{iD});
end
Now you have strings instead of numbers, but they contain the tag to write them green.
[EDITED]: Change line 291 to fix the problem with % and \:
% fprintf(fid,['\t\t\t\t',c,'\n']); % Replace with:
fprintf(fid, '\t\t\t\t%s\n', c);
[EDITED 2]: Change all numerical values in your data cell C to strings including the green tag:
for iC = 1:numel(C)
if isnumeric(C{iC};
C{iC} = sprintf('<font color="#00C000">%g</font>', C{iC});
end
end
10 Comments
mohammad
on 23 Sep 2011
Jan So Much Thanks
where i must insert it Jan?
and for Characters let me try it
mohammad
on 23 Sep 2011
Really perfect Jan
Thanks a lot
now there is no problem with '%',...
please explain more about where i must insert code
Jan
on 23 Sep 2011
I thought you use the above source to modify your data cell.
I've posted an updated method, which modifies all numerical values.
mohammad
on 24 Sep 2011
Jan it works perfect!
thank you
Jan you are so professional in programming!
mohammad
on 24 Sep 2011
and when i use this for string array it doesn't work:
sprintf('<font color="#00C000">%s</font>', C{iC});
Jan
on 24 Sep 2011
Why doesn't this work? Do you get an error message?
mohammad
on 24 Sep 2011
not error
it changes color, but words are a little rubbish
some % and & ,... add to words
i think this is because of editing line 291
Jan
on 24 Sep 2011
Please post an example or the input and output, which causes troubles.
mohammad
on 24 Sep 2011
2-9 S.xls>> main is:'2-9 S.xls'
4-4-8 S.xls>>main is:'4-4-8 S.xls'
7-7-9 F.xls>>main is:'7-7-9 F.xls'
really i don't know how could i thank you, Jan for helping a lot
mohammad
on 24 Sep 2011
Oh Jan sorry, there is a mistake from me.
now there is no problem
it works perfect and so nice!
really thanks dear Jan
More Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)