-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsheet.html
136 lines (116 loc) · 3.84 KB
/
sheet.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://unpkg.com/[email protected]/bundle/read-excel-file.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<style>
table, td, tr, th{
border-style: solid;
border-style: solid;
border-width: 1.5px;
font-size: 12px;
cursor: pointer;
border-color: #33333327;
color: #1a1919;
}
tr{
margin: 5px;
border-style: solid;
border-color: black;
}
.tooltiptext{
display: block;
position: absolute;
border-style: solid;
background-color: blueviolet;
color: #fff;
padding: 10px;
}
</style>
<body>
<input type="file" id="input" accept=".xlsx">
<table id="table">
</table>
<script>
function createElement(tag){
return ()=>{
return document.createElement(tag);
}
}
function timeCheck(){
console.time();
}
function loadingPercentage(lengthOfLoop,indexValue){
let Percent = indexValue / lengthOfLoop * 100;
// console.clear();
let loadingText = Percent + "% loading";
console.log(loadingText);
}
let cell = createElement("tr");
let excelColumns = [];
let finalDataColumns = [];
let x = 0;
input.addEventListener('change', ()=>{
excelColumns = [];
finalDataColumns = [];
// table cleaning
let table = document.getElementById("table");
table.innerHTML = " ";
try{
readXlsxFile(input.files[0]).then(function(rows) {
let counter = 0;
console.time();
rows.forEach(row => {
let tr = createElement("tr"),
cellValue = row,
rowCell = tr();
table.appendChild(rowCell);
for(x = 0; x < row.length; x++){
// console.log(x)
let cell = createElement("td");
td = cell();
td.innerHTML = row[x];
td.setAttribute("name", x)
let column = [];
function collectColumnData(){
let span = createElement("span");
span = span();
// console.log("td")
let cols = document.getElementsByName(x)
for(let a = 0; a < cols.length; a++){
let col = cols[a];
let colValue = col.innerHTML;
column.push(colValue);
loadingPercentage(cols.length, a)
}
excelColumns.push(column);
}
collectColumnData()
rowCell.appendChild(td);
rowCell.addEventListener("click", ()=>{
// rowCell.style.backgroundColor = "blue";
})
}
counter++;
})
console.timeEnd();
let vd = excelColumns.length - x;
let mainCols = excelColumns.length - vd;
for(let v = 0; v < mainCols; v++){
let colX = excelColumns[vd];
finalDataColumns.push(colX)
vd++;
}
console.log(finalDataColumns)
})
}catch(e){
console.log("no file")
}
})
</script>
</body>
</html>