-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuploadxl.js
More file actions
76 lines (57 loc) · 1.61 KB
/
uploadxl.js
File metadata and controls
76 lines (57 loc) · 1.61 KB
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
import React, { useState } from "react";
import * as XLSX from "xlsx";
function Uploadxl() {
const [Sheet1, setItems] = useState([]);
const readExcel = (file) => {
const promise = new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.readAsArrayBuffer(file);
fileReader.onload = (e) => {
const bufferArray = e.target.result;
const wb = XLSX.read(bufferArray, { type: "buffer" });
const wsname = wb.SheetNames[0];
const ws = wb.Sheets[wsname];
const data = XLSX.utils.sheet_to_json(ws);
resolve(data);
};
fileReader.onerror = (error) => {
reject(error);
};
});
promise.then((d) => {
setItems(d);
});
};
return (
<div>
<input
type="file"
accept="xlsx,xlm"
onChange={(e) => {
const file = e.target.files[0];
readExcel(file);
}}
/>
<table className="table container">
<thead>
<tr>
<th scope="col">CondidateName</th>
<th scope="col">Email</th>
<th scope="col">Email</th>
<th scope="col">Email</th>
</tr>
</thead>
<tbody>
{Sheet1.map((d) => (
<tr key={d.CondidateName}>
<th>{d.CondidateID}</th>
<td>{d.Email}</td>
<td>{d.ProfileShortlisted}</td>
</tr>
))}
</tbody>
</table>
</div>
);
}
export default Uploadxl;