Tables
Paul Mansour edited this page Apr 14, 2023
·
8 revisions
Special functions are provided for constructing HTML tables.
The NewTable
function takes a matrix of cell values (text vectors) and optional header and footer values, and produces a table:
d←2 3⍴'One' 'Two' 'Three' 'Four' 'Five' 'Six'
h←'Col1' 'Col2' 'Col3'
t←A.NewTable d h
DOM2HTML t
<table>
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
</thead>
<tbody>
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
</tr>
<tr>
<td>Four</td>
<td>Five</td>
<td>Six</td>
</tr>
</tbody>
</table>
Once the table is created as a DOM object, additional helper functions may be used to extract sets of cell (td
and th
) elements:
b←A.BodyCells t
⍴b
2 3
b.class←(⍴b)⍴'left' 'right' 'right'
Helper functions include Cells
, BodyCells
, HeaderCells
, and FooterCells
.
These functions all return matrices of td
and th
elements.
Header and footer cells, usually specified as vectors rather than matrices, will always return matrices.