IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
cell2html.m
Go to the documentation of this file.
1 %>@ingroup string htmlgen
2 %>@file
3 %>@brief Creates HTML table from cell
4 
5 %> @param cc Cell
6 %> @param flag_header =1. Whether to generate header row
7 %> @param flag_1stcolumn =0. Whether to generate distinguished first column
8 function s = cell2html(cc, flag_header, flag_1stcolumn)
9 
10 
11 if nargin < 2 || isempty(flag_header)
12  flag_header = 1;
13 end;
14 if nargin < 3 || isempty(flag_1stcolumn)
15  flag_1stcolumn = 0;
16 end;
17 
18 [nr, nc] = size(cc);
19 
20 
21 s = ['<table class="bo">', 10];
22 
23 irow = 1;
24 j = 0;
25 if flag_header
26 
27  s = cat(2, s, '<tr>', 10);
28  for j = 1:nc
29  x = cc{1, j};
30  s = cat(2, s, '<td class="bob"><div class="hec">', ...
31  iif(flag_1stcolumn && j == 1, '<div class="bor">', ''), ...
32  iif(isnumeric(x), mat2str(x), x), ...
33  iif(flag_1stcolumn || j == 1, '</div>', ''), ...
34  '</div></td>', 10);
35  end;
36  s = cat(2, s, '</tr>', 10);
37  irow = irow+1;
38 end;
39 
40 
41 for i = irow:nr
42  s = cat(2, s, '<tr>', 10);
43  for j = 1:nc
44  x = cc{i, j};
45  s = cat(2, s, '<td><div class="', iif(isnumeric(x), 'nu', ''), '">', ...
46  iif(flag_1stcolumn && j == 1, '<div class="bor">', ''), ...
47  iif(isnumeric(x), mat2str(x), x), ...
48  iif(flag_1stcolumn || j == 1, '</div>', ''), ...
49  '</div></td>', 10);
50  end;
51  s = cat(2, s, '</tr>', 10);
52 end;
53 
54 s = cat(2, s, '</table>', 10);
55 
function iif(in cond, in x1, in x2)
function cell2html(in cc, in flag_header, in flag_1stcolumn)