-
Notifications
You must be signed in to change notification settings - Fork 0
/
HtmlTable.aplf
43 lines (34 loc) · 1.38 KB
/
HtmlTable.aplf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
HTML←{ALIGN}HtmlTable RCV;ROWTITLES;COLTITLES;VALUES;CRLF;TAB;class;colours;c;tr;thstyle
⍝ LEFT|RIGHT|CENTER HTMLTable RowTitles ColTitles Data
class←''
CRLF←⎕UCS 13 10
colours←'#d8edeb' '#f5fcfc'
:If 0=⎕NC'ALIGN'
ALIGN←'left'
:EndIf
(ROWTITLES COLTITLES VALUES)←RCV
:If 1=≡ALIGN
VALUES←(⊂'<td ',class,' align="',ALIGN,'" valign="top" nowrap>'),¨VALUES,¨(⊂'</td>',CRLF)
:Else
ALIGN←(⍴VALUES)⍴ALIGN 247
VALUES←(⊂'<td ',class,' align="'),¨ALIGN,¨(⊂'" nowrap>'),¨VALUES,¨(⊂'</td>',CRLF)
:EndIf
HTML←'<table cellspacing=1 cellpadding=1 >',CRLF
thstyle←' style="background-color:',(2⊃colours),'"'
:If ''≢COLTITLES
:AndIf ''≢ROWTITLES
HTML,←'<th ',class,' align="left"',thstyle,'> </th>',CRLF
:EndIf
:If ''≢COLTITLES
COLTITLES←(⊂'<th ',class,' align="left" valign="top" nowrap',thstyle,'>'),¨COLTITLES,¨(⊂'</th>',CRLF)
HTML,←∊COLTITLES
:EndIf
HTML,←'</tr>',CRLF
tr←'<tr style="background-color:'∘,¨((≢VALUES)⍴colours),¨⊂'">',CRLF
:If ROWTITLES≡''
HTML,←∊tr,VALUES,⊂'</tr>',CRLF
:Else
ROWTITLES←(⊂'<th ',class,' align="left" valign="top" nowrap>'),¨ROWTITLES,¨(⊂'</th>',CRLF)
HTML,←∊tr,ROWTITLES,VALUES,⊂'</tr>',CRLF
:EndIf
HTML,←'</table>',CRLF