Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions E06Eric.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function geraTabelaHTML() {

let tabela = document.getElementById("Tabela")
let textoCsvDesformatado = document.getElementById("FormularioRecebeCSV").value
let textoCsvDesformatadoString = textoCsvDesformatado.toString()
let csvDivididoEmLinhas = textoCsvDesformatadoString.split("\n")
let linhaInicial = csvDivididoEmLinhas[0].split(",")
let todosElementosString = csvDivididoEmLinhas.toString()
let todosElementosSeparados = todosElementosString.split(",")
let numeroTotalElementos = todosElementosSeparados.length
let numeroDeColunas = linhaInicial.length
let numerodeLinhas = numeroTotalElementos / numeroDeColunas
let indiceTableRow = 0
function geraTrs() {
for (let i = 1; i < numerodeLinhas; i++) {
let tabelasSecas = document.createElement("tr")
tabela.append(tabelasSecas)
}
}
function geraTabela() {
for (i = 0; i <= numeroTotalElementos; i++) {
if (i % numeroDeColunas == 0 && i != 0) {
indiceTableRow++
}
let tableRowAtual = tabela.getElementsByTagName("tr")[indiceTableRow]
let textNodeAtual = document.createTextNode(todosElementosSeparados[i])
let tableDataAtual = document.createElement("td")
tableDataAtual.append(textNodeAtual)
tableRowAtual.append(tableDataAtual)
}
}
geraTrs()
geraTabela()
}
8 changes: 8 additions & 0 deletions sample1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
nome,idade
ulisses,18
eric,16
machado,10
Amanda,17
Benvas,89
claudio,11
cordeio,19
40 changes: 40 additions & 0 deletions siteÉric.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>E06Éric</title>
<script type="text/javascript" src="E06Eric.js"> </script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id = "header">

<p>Insira a tabela CSV :</p>
<div id ="information">
<div >
<textarea id="FormularioRecebeCSV"></textarea>
</div>
<div>
<button name="SubmitFormulario" onclick="geraTabelaHTML()">Enviar</button>
</div>
</div>
</div>
<div id = "resto">
<p>Tabela CSV em HTML:</p>

<table id="Tabela" >


</table>
</div>







</body>
</html>
58 changes: 58 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
*{
margin: initial;
}
#header{

text-align: center;
background-color: #484D51;
width: 100%;
height: 200px;
color: #D2E4F1;
font-size: 2.5em;

}

td, table{

border: 2px solid #99CDA9;

border-collapse: collapse ;
background-color: #E5F4E7;
text-align: center;
padding: 6px;
justify-content: center;

}
body{
background: #D2E4F1;
}
button{
color: #484D51;
background-color: aliceblue;
height: 80px;

border-radius: 8px;




}
textarea{
background-color:aliceblue;
color: #576a77;
margin-left: 50px;
width: 300px;
height: 80px;
border-radius: 8px;
}
#information{
display: flex;
flex-direction: row;
justify-content: center;
margin-top: 20px;
}
#Tabela{
justify-content: center;
}