I've done this sort of thing using a template-based approach where I start
with a character vector containing the formatting I want to use with
place-holders for the data items.

   tmplt=. '<tr><td>{c1}</td>{c2}</td><td>{c3}</td></tr>'

In this case, items in column one are represented by '{c1}' and so on for
the other columns.

   ]mat=. */~>:i.3  NB. Data to put in table
1 2 3
2 4 6
3 6 9

Then I arrange the data so I end up with replacement pairs for each of the
column items:

   ]coltit=. ('{c1}';'{c2}';'{c3}')$~$mat   NB. What we'll replace
+----+----+----+
|{c1}|{c2}|{c3}|
+----+----+----+
|{c1}|{c2}|{c3}|
+----+----+----+
|{c1}|{c2}|{c3}|
+----+----+----+

   ,./|:coltit,:":&.>mat  NB. Line up replacements
+----+-+----+-+----+-+
|{c1}|1|{c2}|2|{c3}|3|
+----+-+----+-+----+-+
|{c1}|2|{c2}|4|{c3}|6|
+----+-+----+-+----+-+
|{c1}|3|{c2}|6|{c3}|9|
+----+-+----+-+----+-+

Finally, I do multiple replacements into the template string using the
standard "rplc" function.

   >(<tmplt) rplc&.><"1 ,./|:coltit,:":&.>mat
<tr><td>1</td>2</td><td>3</td></tr>
<tr><td>2</td>4</td><td>6</td></tr>
<tr><td>3</td>6</td><td>9</td></tr>

This gives me the core HTML for my table.

On Tue, Mar 3, 2015 at 9:40 AM, Chernin, Nadav <chern...@corning.com> wrote:

> Hi,
> I need in my project to represent boxed data in html report
> I try to find some code that can help me to do that
> Thanks
>
> Nadav Chernin
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to