September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
37
Task/Create-an-HTML-table/Stata/create-an-html-table-1.stata
Normal file
37
Task/Create-an-HTML-table/Stata/create-an-html-table-1.stata
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
program mat2html
|
||||
local nr = rowsof(`1')
|
||||
local nc = colsof(`1')
|
||||
local rn `: rownames `1''
|
||||
local cn `: colnames `1''
|
||||
tempname f
|
||||
qui file open `f' using `2', write text replace
|
||||
file write `f' "<!doctype html>" _n
|
||||
file write `f' "<html>" _n
|
||||
file write `f' "<head>" _n
|
||||
file write `f' `"<meta charset="UTF-8">"' _n
|
||||
file write `f' "</head>" _n
|
||||
file write `f' "<body>" _n
|
||||
file write `f' `"<table border="1">"' _n
|
||||
* write column names
|
||||
file write `f' "<tr>" _n
|
||||
file write `f' "<td></td>" _n
|
||||
forv j = 1/`nc' {
|
||||
local s `: word `j' of `cn''
|
||||
file write `f' `"<td>`s'</td>"' _n
|
||||
}
|
||||
file write `f' "</tr>" _n
|
||||
* write row names & data
|
||||
forv i = 1/`nr' {
|
||||
file write `f' "<tr>" _n
|
||||
local s `: word `i' of `rn''
|
||||
file write `f' `"<td>`s'</td>"' _n
|
||||
forv j = 1/`nc' {
|
||||
file write `f' `"<td>`=el(`1',`i',`j')'</td>"' _n
|
||||
}
|
||||
file write `f' "</tr>" _n
|
||||
}
|
||||
file write `f' "</table>" _n
|
||||
file write `f' "</body>" _n
|
||||
file write `f' "</html>" _n
|
||||
file close `f'
|
||||
end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
matrix a=2,9,4\7,5,3\6,1,8
|
||||
matrix rownames a = A B C
|
||||
matrix colnames a = X Y Z
|
||||
mat2html a magic.html
|
||||
Loading…
Add table
Add a link
Reference in a new issue