I am trying to build an electron app that fetches a csv table and displays it as a csv formatted html table
I tried using the code below but the styles are not being applied to the table in the electron window
It is not throwing any error just displaying the table without styles
const csv = `id,species,name
0,Panthera leo,Lion
1,Canis Lupus,Wolf
2,Capra hircus,Goat
3,Panthera pardus,Leopard
4,Equus zebra,Zebra`;
function fetchData() {
return new Promise(res => setTimeout(() => res(csv), 1000));
}
getData();
async function getData() {
//const response = await fetch('new.csv');
//const data = await response.text();
const data = await fetchData();
let a;
a = data.slice(15);
a = a.replaceAll(',', '</td><td>');
a = a.replaceAll('\n', '</tr><tr><td>');
let start = "<table><tr><th>id</th><th>species</th><th>name</th><tr><td></tr>";
let end = "</td></tr></table>";
let semi = start.concat('', a);
a = semi.concat('', end);
a = a.replaceAll('<tr><td></tr></tr>', '');
a = a.replaceAll('</tr>', '</td></tr>');
a = a.replaceAll('</th></td></tr>', '</th></tr>');
a = a.replaceAll('</td></td>', '</td>');
document.write(a);
}
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td,
th {
`enter code here` border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}