Created
September 29, 2021 11:34
-
-
Save josemariagarcia95/6b19e3246e953fc703d91d01f35d75b3 to your computer and use it in GitHub Desktop.
Quick snippet to turn a list of students into a simple HTML table to post on Moodle or similars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readXlsxFile = require('read-excel-file/node') | |
const fs = require('fs'); | |
let file = ` | |
<table border="0" cellpadding="0" cellspacing="0" width="400"> | |
<colgroup> | |
<col width="200"> | |
<col width="200"> | |
<col width="80"> | |
</colgroup> | |
<tbody> | |
<tr height="15"> | |
<td height="15" width="200">Name</td> | |
<td width="200">Surname</td> | |
<td align="right" width="80">Out of 15</td> | |
</tr> | |
`; | |
readXlsxFile('./spanish.xlsx').then((rows) => { | |
for(const row of rows.slice(2)){ | |
file += ` | |
<tr height="15"> | |
<td height="15" width="119">${row[0]}</td> //name | |
<td>${row[1]}</td> //surname | |
<td align="right">${row[7]}</td> //mark | |
</tr> | |
`; | |
} | |
file += ` | |
</tbody> | |
</table><br> | |
`; | |
fs.writeFileSync("./spanish-table.html", file); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment