Skip to content

Instantly share code, notes, and snippets.

@josemariagarcia95
Created September 29, 2021 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josemariagarcia95/6b19e3246e953fc703d91d01f35d75b3 to your computer and use it in GitHub Desktop.
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
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